Commit Graph

52 Commits

Author SHA1 Message Date
Mark Paluch
73eb4ca928 DATACMNS-1081 - Add ReactiveQuerydslPredicateExecutor.
We now ship with a common interface for reactive repositories that want to support Querydsl.

Original Pull Request: #331
2019-01-23 10:23:34 +01:00
Mark Paluch
1969f4bcdc DATACMNS-1459 - Update copyright years to 2019. 2019-01-02 12:12:19 +01:00
Oliver Drotbohm
f2967a919e DATACMNS-1443 - Fixed Querydsl web data binding for blank strings.
We now use StringUtils.hasLength(…) in the check whether to drop request elements from binding instead of ….hasText(…) as the latter drops blank strings so that's impossible to search for properties that contain a blank.
2018-12-10 16:55:26 +01:00
Mark Paluch
666447a4c8 DATACMNS-1293 - Polishing.
Fix leftovers pointing to legacy Querydsl packages in Javadoc. Reformat code.

Original pull request: #284.
2018-04-12 14:34:24 +02:00
Oliver Gierke
408b9abd88 DATACMNS-1235 - Polishing.
Original pull request: #265.
2018-01-10 12:07:22 +01:00
Jens Schauder
9ae4216650 DATACMNS-1235 - Support for package suffix in SimpleEntityPathResolver.
SimpleEntityPathResolver is now a normal class and takes a package suffix in the constructor.

Original pull request: #265.
2018-01-10 12:07:07 +01:00
Mark Paluch
51e7e1b7f5 DATACMNS-1240 - Update copyright years to 2018.
Also, remove some trailing whitespaces and align outdated license header format.
2018-01-08 16:04:34 +01:00
Mark Paluch
fc02b4fd08 DATACMNS-1184 - Fix Javadoc for non-null parameters in QuerydslPredicateExecutor.
Align Javadoc to reflect the non-null contract for Predicate arguments.

Mention unpaged/unsorted factory methods for Pageable/Sort arguments.

Related ticket: DATACMNS-1114.
2017-10-02 10:04:42 +02:00
Oliver Gierke
404610ebb4 DATACMNS-1168 - QuerydslPredicateBuilder now returns empty predicate by default. 2017-09-21 16:23:40 +02:00
Oliver Gierke
049970874d DATACMNS-1114 - Introduced usage of nullable annotations for API validation.
Marked all packages with Spring Frameworks @NonNullApi. Added Spring's @Nullable to methods, parameters and fields that take or produce null values. Adapted using code to make sure the IDE can evaluate the null flow properly. Fixed Javadoc in places where an invalid null handling policy was advertised. Strengthened null requirements for types that expose null-instances.

Removed null handling from converters for JodaTime and ThreeTenBP. Introduced factory methods Page.empty() and Page.empty(Pageable). Introduced default methods getRequiredGetter(), …Setter() and …Field() on PersistentProperty to allow non-nullable lookups of members. The same for TypeInformation.getrequiredActualType(), …SuperTypeInformation().

Tweaked PersistentPropertyCreator.addPropertiesForRemainingDescriptors() to filter unsuitable PropertyDescriptors before actually trying to create a Property instance from them as the new stronger nullability requirements would cause exceptions downstream.

Lazy.get() now expects a non-null return value. Clients being able to cope with null need to call ….orElse(…).

Original pull request: #232.
2017-07-24 10:47:28 +02:00
Oliver Gierke
d9b16d8a27 DATACMNS-1085 - Fixed typos in Javadoc.
Original pull request: #229.
2017-07-24 10:32:19 +02:00
Oliver Gierke
17af937194 DATACMNS-1059 - Polishing.
Original pull request: #215.
2017-05-19 09:22:23 +02:00
Christoph Strobl
8c028c3115 DATACMNS-1059 - Alter QuerydslPredicateExecutor.findOne(…) to return Optional<T>.
We now return Optional<T> for QuerydslPredicateExecutor.findOne(Predicate) aligning the return type to the ones used in CrudRepository.

Original pull request: #215.
2017-05-19 09:22:23 +02:00
Oliver Gierke
3fb7c870fb DATACMNS-1057 - SingleValueBinding now returns a non-Optional again.
The binding is populated with a value so we can also expect a predicate to be returned.
2017-05-04 23:14:43 +02:00
Oliver Gierke
727ab8384c DATACMNS-944 - Moved to more consistent naming scheme for CrudRepository methods.
We now follow a more consistent naming scheme for the methods in repository that are driven by the following guidelines:

* Methods referring to an identifier now all end on …ById(…).
* Methods taking or returning a collection are named …All(…)

That results in the following renames:

* findOne(…) -> findById(…)
* save(Iterable) -> saveAll(Iterable)
* findAll(Iterable<ID>) -> findAllById(…)
* delete(ID) -> deleteById(ID)
* delete(Iterable<T>) -> deleteAll(Iterable<T>)
* exists() -> existsById(…)

As a side-effect of that, we can now drop the Serializable requirement for identifiers.

Updated CRUD method detection to use the new naming scheme and moved the code to Java 8 streams and Optional. Adapted RepositoryInvoker API to reflect method name changes as well.
2017-05-03 17:49:50 +02:00
Mark Paluch
14647f9192 DATACMNS-1021 - Add Order.asc(…) and Order.desc(…) factory methods.
We now support Order creation with Order.asc(String) and Order.desc(String) factory methods as shortcut to constructor creation via new Order(Direction, String).

Sort.by(Order.asc("age"), Order.desc("name"));

Deprecated Order(String) constructor in favor of the Order.by(String) factory method. Replace references to new Order(String) with Order.by(String).

Original pull request: #211.
2017-04-26 16:48:40 +02:00
Oliver Gierke
ba875187cd DATACMNS-867 - RepositoryInvoker.invokeQueryMethod(…) now returns an Optional. 2017-03-24 08:00:46 +01:00
Oliver Gierke
fee153f724 DATACMNS-867 - RepositoryInvoker now returns an Optional for invokeFindOne(…).
Adapted ReflectionRepositoryInvoker to transparently unwrap other potentially used wrapper types to then convert the result into an Optional.
2017-03-24 08:00:46 +01:00
Oliver Gierke
dec820d6c2 DATACMNS-867 - Removed handling of null Pageables.
Pageable now exposes a dedicated null-object representing the absence of pagination so that all places that previously handled null values can now rather be more relaxed and assume that a non-null value is given.
2017-03-24 08:00:46 +01:00
Oliver Gierke
917c3e2889 DATACMNS-867 - Removed Optional from QuerydslBindingsFactory API. 2017-03-24 08:00:45 +01:00
Christoph Strobl
be347eaaab DATACMNS-867 - Additional Java 8 language feature cleanup.
Make use of lambdas and method references though out the codebase. Remove no longer required generic type parameters.
Additionally remove unused imports and replace single element list initialization with dedicated singletonList.
Use Assertion overloads taking Supplier for dynamic assertion error messages.
2017-03-24 08:00:43 +01:00
Oliver Gierke
250b1cf613 DATACMNS-867 - Cleanups in Querydsl support. 2017-03-24 08:00:42 +01:00
Oliver Gierke
9c6f764131 DATACMNS-867 - Consistent non-capitalization of Querydsl. 2017-03-24 08:00:42 +01:00
Oliver Gierke
2210f2e8e9 DATACMNS-867 - Adapt codebase after rebase on forward ports. 2017-03-24 08:00:36 +01:00
Oliver Gierke
d4811e29d9 DATACMNS-867 - Second draft. 2017-03-24 08:00:23 +01:00
Oliver Gierke
cc63e5b7a4 DATACMNS-867 - First draft. 2017-03-24 08:00:23 +01:00
Mark Paluch
8bafe7964b DATACMNS-973 - Polishing.
Convert @see http://… links to valid format using @see <a href=…>…</a>.
2017-01-13 08:50:54 +01:00
Oliver Gierke
f93d2df4f1 DATACMNS-941 - Support for downcasts in Querydsl web bindings.
We now support downcasts (e.g. user.as(QSpecialUser.class).…) expressions in Querydsl web binding. We do so by skipping the introduced intermediate step in the path when calculating the dot path.

Refactored the internals of the binding to now work based on a PathInformation implementation for which either a Querydsl Path or a Spring Data PropertyPath can be used. This allows us to reuse the paths of predefined bindings.

A bit of Lombok cleanup in internal implementations.
2016-12-12 16:34:18 +01:00
Oliver Gierke
f2a6d63dbb DATACMNS-883 - Improved collection path binding for Querydsl-backed web requests.
Improved the dot-path translation of existing Querydsl Path instances by not relying on the toString() representation of the metadata but manually traversing the elements up to the root. Extracted the translation method into QueryDslUtils.

Furthermore, we now automatically insert an CollectionPathBase.any() step for Path instances of that type when reifying the paths from request attributes.
2016-07-15 11:39:43 +02:00
Oliver Gierke
3ed2f44e60 DATACMNS-787 - QuerydsBindings now allows aliasing of paths.
If a single path is now handed to QuerydslBindings.bind(…), a specialized AliasingPathBinder is returned which allows defining an alias the binding will be exposed under.

By default that alias will cause the original binding being black-listed and thus become unavailable for binding. This can be overridden by explicitly white-listing the properties to be bindable.
2015-11-23 13:07:19 +01:00
Oliver Gierke
c013c71e7a DATACMNS-670 - Upgraded to Querydsl 4.
Switched to new Querydsl 4 artifacts and adapted to changed package names and API changes.

Cleaned up some JavaDoc and APIs in QuerydslBindingsFactory and QuerydslBinderCustomizer.
2015-11-17 11:07:05 +01:00
Oliver Gierke
d3a194c408 DATACMNS-779 - Fixed JavaDoc in QuerydslPredicateBuilder.
Added JavaDoc to the constructor of QuerydslPredicateBuilder.
2015-10-22 11:45:17 +02:00
Oliver Gierke
8c90594e9e DATACMNS-760 - Removed cyclic dependency in Querydsl packages.
Moved @QuerydslPredicate into the non-web-related Querydsl package to avoid a cyclic dependency.
2015-09-01 09:23:04 +02:00
Oliver Gierke
cc2696fcc4 DATACMNS-755 - Fixed QSort property translation for plain paths.
If standard Querydsl StringPaths are used without any reference to a query class tree, we previously dropped the first segment of the path expression.

Moved to a completely different algorithm to determine the path by just using the Path's toString() representation and the root removed if necessary.
2015-08-18 13:53:02 +02:00
Oliver Gierke
8d2933f109 DATACMNS-669 - Introduced QuerydslBindingsFactory.
QuerydslBindingsFactory creates a completely build up and customized QuerydslBindings instance for a given QuerydslBinderCustomizer type and domain type.

This basically involves creating or obtaining an instance of the customizer with the following algorithm:

1. If an explicit customizer type is given and no BeanFactory is configured, we'll simply instantiate the configured type. This allows simple customizer implementations with a no-arg constructor.
2. If a BeanFactory is configured and a customizer type configured, we're trying to locate a bean of that type in the BeanFactory, falling back to creating an instance of the customizer through the BeanFactory if no existing bean definition can be found. This allows unique customizer bean definitions or complex prototype scoped customizer beans created on the fly.
3. If no customizer type is configured, we check whether the the repository of the domain type implements QuerydslBinderCustomizer and use it if so.

The extraction of that functionality allows that algorithm being used by Spring Data REST, although only step 3 is currently used there as no explicit customizer can currently be configured with Spring Data REST.
2015-08-03 15:34:47 +02:00
Oliver Gierke
e3668c621d DATACMNS-734 - Improved Querydsl predicate binding using formatters.
We now default to a FormattingConversionService to make sure comma-separated values are transformed into arrays correctly. Also, we now build up dedicated TypeDescriptor instances for the property or field about to be bound to potentially pick up formatting annotations on those.
2015-07-21 15:47:09 +02:00
Christoph Strobl
11056be292 DATACMNS-734 - Allow comma separated list of values to be bound to an array.
We now convert comma separated values for an array property by splitting values and converting each of them. This allows to convert address.location=40.740337,-73.995146 to 

class Address {
  Double[] location;
}
2015-07-21 15:47:09 +02:00
Oliver Gierke
c5e5244162 DATACMNS-669 - Moved some types for better code structure.
Introduced dedicated querydsl.bindings package to contain all non-web projects to make sure domain types and repositories don't have to depend on types in a web package.

Updated Sonargraph architecture description accordingly.

Original pull request: #132.
2015-07-20 08:12:28 +02:00
Oliver Gierke
cccfa5e5c5 DATACMNS-669 - Polishing.
Javadoc on MultiValueBinding. Hide QuerydslBindings.bind(…), ….include(…) and ….exclude(…) methods that take String arguments to reduce the probability of no query class being present.

Refined the value handling for empty request values which are represented as String[] containing an empty String. We now massage those into an empty Collection for MultiValueBindings and a null value for SingleValueInvocations.

We currently skip property values that match this pattern entirely but are prepared to allow a configuration flip switch to handle those scenarios in the future. We currently stick to skipping those values to prevent the bindings from having to deal with null values.

We now also allow the bindings to return null to indicate they don't want to get applied in the resulting predicate at all.

Switched to interface based customization to make it easier to use customizations with Spring Data REST. Added Querydsl-specific adapter of RepositoryInvoker to allow Spring Data REST to hook in the execution of the predicate obtained from request parameters.

Original pull request: #132.
2015-07-20 08:12:11 +02:00
Thomas Darimont
ec643d21cb DATACMNS-554 - Added QueryDslPredicateExecutor.findAll(Predicate, Sort).
We now support findAll on QueryDslPredicateExecutor that accepts a Querydsl Predicate and a Sort.

Original pull request: #115.
2015-02-24 09:40:16 +01:00
Thomas Darimont
0fb572b550 DATACMNS-636 - Add QueryDslPredicateExecutor.exists(…) which accepts a Querydsl predicate.
Original pull request: #112.
2015-01-26 11:03:13 +01:00
Oliver Gierke
b2251aa5b9 DATACMNS-621 - Polishing.
Simplified implementation of Path conversion. Inlined helper domain types to not to pollute the packages with types that are only used within that very one test class.

Original pull request: #111.
2015-01-20 16:31:30 +01:00
Christoph Strobl
95bda862e7 DATACMNS-621 - QSort now treats nested paths correctly.
We now inspect intermediate path elements to build sort order accordingly.

Original pull request: #111.
2015-01-20 16:25:52 +01:00
Oliver Gierke
90a9462221 DATACMNS-587 - Added findAll(OrderSpecifier… orders) to QueryDslPredicateExecutor.
QueryDslPredicateExecutor now has a findAll(…) method to take multiple OrderSpecifiers to order the results. Polished JavaDoc along the way.
2014-11-28 10:02:19 +01:00
Thomas Darimont
5448b3e63b DATACMNS-604 - Move QueryDsl helper methods from QueryDslUtils to KV package.
Moved to new class KeyValueQueryDslUtils in order to avoid class loading issues.

Original pull request: #107.
2014-11-27 12:29:34 +01:00
Christoph Strobl
e2358f3bf8 DATACMNS-525 - Introduce infrastructure for KeyValue repositories.
Added basic infrastructure for repositories on top of key-value data stores. For more details see the original pull request.

Original pull request: #95.
2014-11-26 16:43:15 +01:00
Oliver Gierke
e1b38faee9 DATACMNS-601 - Fixes for most of the SonarQube warnings. 2014-11-26 09:25:14 +01:00
Thomas Darimont
48966b50d6 DATACMNS-577 - Improved JavaDoc on QueryDslPredicateExecutor.
Clarified return values if predicates don't match or return multiple results (for the findOne(…) method). Copied summary to the @return tag.

Original pull request: #96.
2014-10-08 06:46:55 +02:00
Thomas Darimont
9fc57ea3bf DATACMNS-566 - Allow sorting by QueryDsl operator expressions.
Previously we only allowed to sort by QueryDsl path expressions. With this change we now also support ordering by operator expressions, e.g. yearMonth() on a date property.

Original pull request: #94.
2014-08-26 13:56:17 +02:00
Oliver Gierke
62e14d2b12 DATACMNS-402 - Slight refinements in QSort implementation.
Re-enable concatenation with plain Sort via ….and(…) method. Some general polishing and JavaDoc cleanups.

Original pull request: #59.
2013-12-04 13:30:19 +01:00