From 3b977216a602ead6032502ed7331a04564b72811 Mon Sep 17 00:00:00 2001 From: Marcel Overdijk <marcel@overdijk.me> Date: Tue, 28 Mar 2017 14:51:07 +0200 Subject: [PATCH 1/2] Added querydsl default bindings support --- .../binding/QuerydslBindingsFactory.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java index 1261daaadf..97bd4cdf25 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java @@ -44,6 +44,8 @@ public class QuerydslBindingsFactory implements ApplicationContextAware { private final EntityPathResolver entityPathResolver; private final Map<TypeInformation<?>, EntityPath<?>> entityPaths; + private QuerydslBinderCustomizer defaultBindings; + private AutowireCapableBeanFactory beanFactory; private Repositories repositories; @@ -60,6 +62,20 @@ public QuerydslBindingsFactory(EntityPathResolver entityPathResolver) { this.entityPaths = new ConcurrentReferenceHashMap<TypeInformation<?>, EntityPath<?>>(); } + /** + * Creates a new {@link QuerydslBindingsFactory} using the given {@link EntityPathResolver} and default bindings + * {@link QuerydslBinderCustomizer}. + * + * @param entityPathResolver must not be {@literal null}. + * @param defaultBindings the default bindings {@link QuerydslBinderCustomizer} to apply to each {@link QuerydslBindings} + * created by this factory. + */ + public QuerydslBindingsFactory(EntityPathResolver entityPathResolver, QuerydslBinderCustomizer defaultBindings) { + this(entityPathResolver); + + this.defaultBindings = defaultBindings; + } + /* * (non-Javadoc) * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) @@ -97,6 +113,11 @@ public QuerydslBindings createBindingsFor(Class<? extends QuerydslBinderCustomiz EntityPath<?> path = verifyEntityPathPresent(domainType); QuerydslBindings bindings = new QuerydslBindings(); + + if (defaultBindings != null) { + defaultBindings.customize(bindings, path); + } + findCustomizerForDomainType(customizer, domainType.getType()).customize(bindings, path); return bindings; From 0e86c0845092c90c44f805c88c7cdf0c66f49972 Mon Sep 17 00:00:00 2001 From: Marcel Overdijk <marcel@overdijk.me> Date: Tue, 28 Mar 2017 14:54:45 +0200 Subject: [PATCH 2/2] Updated author tag + amended date range --- .../data/querydsl/binding/QuerydslBindingsFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java index 97bd4cdf25..0ac7830bc9 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ * Factory to create {@link QuerydslBindings} using an {@link EntityPathResolver}. * * @author Oliver Gierke + * @author Marcel Overdijk * @since 1.11 */ public class QuerydslBindingsFactory implements ApplicationContextAware {