Commit Graph

160 Commits

Author SHA1 Message Date
Oliver Gierke
40648c82a7 Formatting. 2011-08-16 17:47:12 +02:00
Oliver Gierke
1ee347cf40 DATACMNS-59 - AbstractQueryCreator now handles static and dynamic sorting combined.
Added and(…) method to Sort to combine two Sort instances and produce a resulting Sort.
2011-08-16 17:47:00 +02:00
Oliver Gierke
ba3cbe7244 DATACMNS-57 - TypeDiscoverer now discovers generic constructor parameters correctly.
Fixed formatting for unit test as well.
2011-07-28 17:46:57 +02:00
Oliver Gierke
30de1d55b7 DATACMNS-56 - Tweak to algorithm of PreferredConstructorDiscoverer to pick up single argument-taking constructor. 2011-07-25 23:38:18 +02:00
Oliver Gierke
2c538dbb15 DATACMNS-56 - PreferredConstructorDiscoverer does not throw an exception in case no preferred constructor is found. 2011-07-25 23:02:27 +02:00
Oliver Gierke
596a03c04c DATACMNS-55 - TypeDiscoverer now handles types extending Collections and Maps as well. 2011-07-25 22:59:14 +02:00
Oliver Gierke
abfe323e75 Removed unused import. 2011-07-19 17:34:31 +02:00
Oliver Gierke
751ca2ae22 DATAJPA-71 - Tweaked AbstractQueryCreator to be more flexible.
AbstractQueryCreator is now more lenient. We're now allowing instantiation without a ParameterAccessor for implementations that don't want to do parameter binding during query creation. We additionally provide a createQuery(Sort) now to allow handing in a dynamic Sort parameter taken from a query method to apply sorting even in case we don't bind parameters directly.

Added a method to Parameters to discover whether we potentially sort dynamically which simply tests for a Sort or Pageable parameter in the method signature.
2011-07-19 08:58:39 +02:00
Oliver Gierke
6e79fcbde0 Polished JavaDoc. 2011-07-15 10:09:35 +02:00
Oliver Gierke
954c74b788 DATACMNS-52 - Redeclared methods in intermediate repository interfaces are now discovered correctly.
We deeply have to resolve the generic types before doing the type comparison. Tweaked DefaultRepositoryInformation and added test cases.
2011-07-13 20:27:12 +02:00
Oliver Gierke
5a6427fdcf DATACMNS-50 - Added ability to define PersistentProperty order for PersistentEntities.
BasicPersistentEntity now has a constructor taking a Comparator and holds PersistentProperty instances in a TreeSet if a COmparator is given at construction. Removed getPersistentPropertyNames() from PersistentProperty interface as it's not used anywhere.
2011-07-06 18:04:52 +02:00
Oliver Gierke
7b3e61e050 DATACMNS-49 - Added infrastructure to read queries from a Properties file.
Added NamedQueries abstraction to hide a map of names to manually defined queries. Added PropertiesBasedNamedQueries to hold the named queries in a Properties instance. Extended resolveQuery(…) method in QueryLookupStrategy to take a NamedQuery instance to allow query creation callback use the named queries.

Added optional 'named-queries-location' attribute to the repositories namespace the bean definition parser loads the properties from to populate a PropertiesBasedNamedQueries instance and pipe it into the repository factory. Store implementations have to default the name to lookup in their RepositoryConfiguraion class (see CommonRepositoryConfigInformation.getNamedQueriesLocation()).
2011-06-23 19:05:49 +02:00
Oliver Gierke
dc50f489ba DATACMNS-48 - Renamed QueryExecuterMethodInterceptor to QueryExecutorMethodInterceptor. 2011-06-21 21:58:59 +02:00
Oliver Gierke
dcd4f0772c Exposing owner type for Property. 2011-06-17 19:41:37 +02:00
Oliver Gierke
6ddcad6998 Property instances can now be created from a dot notation as well.
Some JavaDoc polishing. Removed private method to lookup actual property type (read transparently resolving collection component and map value types) over TypeInformation.getActualType().
2011-06-17 19:41:37 +02:00
Oliver Gierke
3addb9c2f8 Added TypeInformation.getActualType().
The method transparently resolves the property type, collection component type or map value type depending on what the core type is.
2011-06-17 19:41:36 +02:00
Oliver Gierke
e86721fbdb Added MappingContext.getPersistentPropertyPath(…).
The method allows to get PersistentProperty instances for a given path expression.
2011-06-17 19:36:57 +02:00
Oliver Gierke
23dbfe27bb Added getType() method to Parameter value object. 2011-06-15 19:43:08 +02:00
Oliver Gierke
d2e46f6770 JavaDoc polishing. 2011-06-15 19:42:47 +02:00
Oliver Gierke
736b8adf08 Refactored package structure.
Resolved dependency cycles in repository and mapping packages. Introduced repository.core package as well as core.support where most of the type of former repository.support is in now. New repository.support only contains additional stuff built on top of core repository abstraction (e.g. Converters, PropertyEditors). Added some more unit tests to core mapping abstractions and removed not needed methods from its API.
2011-06-13 20:23:26 -07:00
Oliver Gierke
5650b068ed DATACMNS-31 - Added null check to SimpleTypeHolder.isSimpleType(…).
The MappingBeanHelper mentioned in the ticket was recently replaced by SimpleTypeHolder.
2011-06-10 15:03:08 -07:00
Oliver Gierke
7a13657eb5 DATACMNS-169 - Reworked simple type handling in mapping subsystem.
All simple type discovery is now done through a SimpletypeHolder instance that carries a few default types considered to be simple but is configurable to carry additional ones. The mapping subsystem uses an instance of that class to do simple type decisions and thus allows customizing what is to be considered a simple type by simply dependency injecting a value object.
2011-06-09 16:26:48 -07:00
Oliver Gierke
351e37e4eb DATACMNS-45 - Improved property handling in TypeDiscoverer and Property.
TypeDiscoverer now looks up property type using a PropertyDescriptor if no field with the given name can be found. Property now handles _-prefixed properties as well.
2011-06-07 15:49:26 -07:00
Oliver Gierke
3453806569 DATACMNS-44 - Fixed BindableParameterIterator.hasNext(). 2011-06-07 12:43:41 -07:00
Oliver Gierke
d5300ed1bc DATACMNS-43 - Corrected exception message in PreferredConstructorDiscoverer to mention PersistenceConstructor. 2011-06-07 11:50:28 -07:00
Oliver Gierke
364a84ffb8 DATACMNS-42 - MappingBeanHelper now considers all Numbers to be simple types.
Fixed bug in isSimpleType(…) along the lines.
2011-06-06 14:44:28 -07:00
Oliver Gierke
12d5c0ddb9 Polished JavaDoc. 2011-06-06 11:07:21 -07:00
Oliver Gierke
70da7b00f8 DATACMNS-41 - Refactored DefaultRepositoryInformation to take custom implementation class into account as well. 2011-06-01 00:29:52 +01:00
Oliver Gierke
399bc5e6bf Made DefaultRepositoryInformation public. 2011-05-31 22:34:59 +01:00
Oliver Gierke
0ea1921a96 Updated reference documentation regarding repository declaration.
Polished Javadoc of Repository to mention possibility of selectively exposing CRUD methods.
2011-05-24 12:33:18 +02:00
Oliver Gierke
dab13128f4 Introduced BeanWrapper helper object to reduce static access through MappingBeanHelper.
Creating bean instances, getting and setting properties on a bean was done by using static methods on MappingBeanHelper so far. This required certain Spring components (ConversionService) being held statically as well. Beyond that various Spring components had set these static values which might cause strange behavior if multiple instances of these Spring components are created. Thus we now have a BeanWrapper that takes the formerly statically held instances and uses those for bean creation and property access.

Moved SpEL awareness of a mapping into SpELAwareParameterValueProvider to hide it behind an ParameterValueProvider instance.
2011-05-24 12:31:59 +02:00
Oliver Gierke
be5d43900c Moved QueryDslPredicateExecutor into Spring Data Commons. 2011-05-23 12:21:01 +02:00
Oliver Gierke
637daac97b DATACMNS-40 - Renamed @RepositoryProxy to @RepositoryDefinition. 2011-05-23 11:50:11 +02:00
Oliver Gierke
1583aea2b7 DATADOC-145 - Removed obsolete methods from MappingBeanHelper.
Fixed inverted isAssignableFrom(…) check as well.
2011-05-22 14:44:05 +02:00
Thomas Risberg
cbf8218cc0 added UserCredentials class to support DATADOC-142 2011-05-20 12:40:10 -04:00
Oliver Gierke
7a110d593e DATACMNS-38 - Prevent StackOverflow on self referencing objects.
Various improvements and additional test cases for the TypeInformation abstraction. Introduced ParameterizedTypeInformation in-between class to take the parent into account when calculating equals(…) and hashCode(). We're also shortcutting TypeInformation creation if the parent's underlying type equals the one we shall create a new TypeInformation for.

Slightly modified the parsing algorithm when adding PersistentEntity objects. We now eagerly add them to the cache to prevent endless recursive adding.
2011-05-17 20:15:52 +01:00
Oliver Gierke
66c77820c4 DATACMNS-37 - Added unit tests for annotation based repository usage. 2011-05-17 20:15:38 +01:00
Oliver Gierke
1761255c2d DATACMNS-37 - Enabled annotation based repository declaration model.
Introduced an @RepositoryProxy annotation that can be used as alternative to extending Repository. Added necessary RepositoryMetadata implementation to introspect the annotation rather than the generic types. Enabled bean definition parsers to pick up annotation based repositories as well.
2011-05-14 08:37:38 +02:00
Oliver Gierke
22f3e5cd1c Added test case to check whether declaring a CRUD method in a repository interface extending Repository is delegated to the backing bean. 2011-05-13 10:03:48 +02:00
Oliver Gierke
138191fd19 DATACMNS-34 - Fixed exception message to include class name and point to argument constructors, not no-arg ones. 2011-05-13 10:02:58 +02:00
Oliver Gierke
24394b4f1d DATACMNS-29 - Extracted Repository marker interface from CrudRepository.
This change allows creating repository proxies without exposing CRUD methods at the same time. This essentially enables query-method-only repository interfaces.
2011-05-12 13:17:55 +02:00
Oliver Gierke
d8c5bca4bd DATACMNS-36 - Improved transaction handling configuration support.
Added custom TransactionAttributeSource that favors interface transaction configuration over the implementation configuration. This allows us configuring repository implementations with @Transactional but allow overriding this configuration at the user's repository level as well.
2011-05-12 12:13:49 +02:00
Oliver Gierke
88bad20ab3 DATACMNS-29 - Added getRepositoryInterface() implementation to RepositoryConfig.
We now assume scanning for all sub-interfaces of Repository by default now. Thus concrete modules can pretty much drop the implementation of this method in their concrete config implementations in case they support picking up user's repository interfaces that extend Repository only.

From a users perspective this drops the requirement to extend a persistence technology specific interface (MongoRepository, JpaRepository and the like).
2011-05-12 11:35:16 +02:00
Oliver Gierke
891144b543 DATACMNS-35 - Added delete(ID id) method to Repository interface. 2011-05-11 18:37:15 +02:00
Oliver Gierke
06872f23f5 Set fields and getter accessible before reading value in MappingBeanHelper. 2011-05-11 18:36:44 +02:00
Oliver Gierke
6f92b010d3 DATAJPA-59 - Added unit test for QueryMethod. 2011-05-11 13:27:51 +02:00
Jon Brisbin
e67e35ac8d Reformatting source code to use tabs instead of spaces. 2011-05-10 10:50:32 -05:00
Oliver Gierke
870d156adb DATACMNS-34 - Improved algorithm to lookup preferred constructor.
Algorithm is now was follows:

1. If there's no explicit constructor use the default constructor.
2. If there's a single explicit constructor, use this one.
3. If there's multiple explicit constructors and one has been annotated with @PersistenceConstructor use the annotated one.
4. If there's multiple explicit constructors and none annotated use the no-arg one or throw an exception to resolve the ambiguity.

Test cases for that algorithm are located in PreferredConstructorDiscovererUnitTests. Refactored PreferredConstructor and Parameter classes a little to make them immutable value objects. Introduced ability to lookup parameter TypeInformation for constructors on TypeInformation interface.

Extended generics in mapping subsystem to allow defining a concrete subtype of PersistentProperty as well. Removed some generics related compiler warnings as well.
2011-05-10 10:15:46 +02:00
Oliver Gierke
ff51b134f9 DATADOC-43 Added Near and Within as part types to support spatial repository queries. 2011-05-03 15:12:22 +02:00
Oliver Gierke
54ada02ae8 DATADOC-109 - Refactored mapping subsystem.
Refactored BasicMappingContext into AbstractMappingContext that now only contains the general algorithm to build PersistentEntity and PersistentProperty instances. The algorithm delegates to two template methods that are responsible for instantiating concrete implementations of those classes.

Extracted an AnnotationBasedPersistentProperty that now contains all annotation references so that AbstractPersistentEntity does not take annotations into account in the first places. BasicPersistentEntity now does PreferredConstructor lookup as well.

Removed unnecessary methods from MappingCOntext and PersistentEntity interface. Added a verify() method to BasicPersistentEntity that AbstractMappingContext calls to verify validity of the entity. This will be used by the Mongo module for example to make sure @Document annotated entities have an @Id property.

Refactored getValueAnnotation() to getSpelExpression() to not imply we're using annotations in every case.

Added shortcut in TypeDiscoverer.createInfo(…) to prevent endless loop in case a type has a field of it's very same type.

TypeDiscoverer now returns the plain compound type for arrays now, which means you get String for String[], String[][] and so on. Opened up signature of AbstractMappingContext.setInitialEntitySet(…) to allow effortless programatic invocation.
2011-04-28 21:34:08 +02:00