Commit Graph

287 Commits

Author SHA1 Message Date
Aleksander Blomskøld
f0ffd0316c DATACMNS-221 - Added support for Unicode characters in PartTree.
Altered parsing regular expressions to support unicode characters.
2012-09-04 09:08:11 +02:00
Oliver Gierke
4939fbf3bc DATACMNS-226 - Fixed bug in ConfigurableTypeInformationMapper caching.
Separated ConfigurableTypeInformationMapper from MappingContextTypeInformationMapper. The latter now lazily picks up the alias information if the cached values do not contain aliases.

Polished JavaDocs and clarified meaning of null values.
2012-09-03 13:36:34 +02:00
Oliver Gierke
6d2d22954f DATACMNS-218 - Expose RevisionMetadata from Revision. 2012-08-23 18:51:50 +02:00
Oliver Gierke
307e003902 DATACMNS-214 - Simple types are not considered PersistentEntities anymore.
Before actually adding a type as PersistentEntity, AbstractMappingContext will call shouldCreatePersistentEntityFor(TypeInformation<?> type) now. The default implementation will just consider the SimpleTypeHolder for that decision. However as adding a Converter to the context will render the converted object to be treated as simple, one might want to override this method to be more precise and only rule out store-specific simple types at this stage.
2012-08-16 12:55:07 +02:00
Oliver Gierke
0fc753f151 DATACMNS-211 - Fixed component type resolving for arrays.
ClassTypeInformation does not resolve nested array types anymore as a multidimensional array in fact has a component type of an array of one dimension less, e.g. String[][].getComponentType() -> String[].
2012-08-16 12:52:25 +02:00
Oliver Gierke
c6b04618b9 DATACMNS-216 - Removed deprecations from AbstractMappingContext.
Removed the deprecation as it might still be necessary to set the ApplicationEventPublisher to emit MappingContextEvents.
2012-08-16 12:52:24 +02:00
Oliver Gierke
d9e5d92a16 DATACMNS-207 - Removed getPropertyDescriptor() from PersistentProperty. 2012-08-16 12:52:24 +02:00
Oliver Gierke
beea916da0 DATACMNS-215 - Removed validators from MappingContext API. 2012-08-16 12:52:24 +02:00
Oliver Gierke
35d96afac6 DATACMNS-212 - Sonargraph checks and improvements.
Merged mapping.context and mapping.event packages. Moved MappingContext event into context package. Updated Sonargraph architecture description and completed package and dependency mapping.
2012-08-13 14:26:40 +02:00
Oliver Gierke
27a8a8df91 DATACMNS-47 - Guard against @EnableRepositories annotations not carrying @Inherited.
If an @EnableRepository annotation does not carry an @Inherited annotation and the annotation is used in a JavaConfig inheritance scenario the ImportBeanDefinitionRegistrar gets invoked without the annotation metadata available. The RepositoryBeanDefinitionRegistrarSupport now guards against that case and will not invoke registration of repository bean definitions. It's strongly recommended to equip @EnableRepository annotations with @Inherited to accommodate this scenario.
2012-08-13 11:23:52 +02:00
Oliver Gierke
f1aff4ed10 DATACMNS-211 - Improved TypeInformation abstraction. 2012-08-07 19:28:30 +02:00
Oliver Gierke
f532404521 DATACMNS-206 - Guard against PropertyDescriptor being null.
Added guards to PropertyDescriptor access to prevent NullPointerExceptions in cases it is not given in the first place. Polished JavaDoc for test case.
2012-07-31 15:41:56 +02:00
Oliver Gierke
fc57f602e9 DATACMNS-209 - MappingContextEvent now carries its emitting MappingContext.
MappingContextEvent now has an wasEmittedBy(MappingContext<?, ?> context) method to allow identifying whether the event was emitted by the given MappingContext. Useful if multiple MappingContexts are in place and one wants to react on the events emitted by a particular one only.
2012-07-31 15:38:16 +02:00
Oliver Gierke
583a60baed DATACMNS-206 - Improved working with getters and setters for PersistentProperty.
PersistentProperty now exposes getGetter() and getSetter() methods which restrict the methods being returned to return or accept type compatible values to the actual properties type. Thus when you implement a custom getter or setter which - by the definition of the JavaBean spec - would qualify as read or write method for a particular property, we now ensure that they are only considered if they match the type of the field exposed.
2012-07-24 15:12:04 +02:00
Oliver Gierke
f476100f28 DATACMNS-203 - Re-enabled accidentally disabled unit tests. 2012-07-23 17:37:47 +02:00
Oliver Gierke
c64f01414f DATACMNS-164 - Added support for XML/JSON marshaling of Page, Pageable and Sort.
Added XmlTypeAdapter implementations that convert the PageImpl, PageRequest and Sort value objects into a JAXB marshalable object.
2012-07-23 17:27:17 +02:00
Oliver Gierke
cf71070de6 DATACMNS-202 - Move helper classes for BeanDefinitionParses into Commons. 2012-07-18 23:14:28 +02:00
Oliver Gierke
d7df08f6b7 DATACMNS-201 - Fixed critical FindBugs warnings. 2012-07-18 20:53:24 +02:00
Oliver Gierke
96795f2980 DATACMNS-47 - Add support for JavaConfig based repository configuration.
Completely rewrote namespace bean definition parsing to be extendable more easily. Separated XML concerns from annotation based configuration. The central point to extend the namespace parsing for a certain module is now hidden behind the RepositoryConfigurationExtension interface (have a look at the RepositoryConfigurationExtensionSupport base class as well).
2012-07-16 19:49:56 +02:00
Oliver Gierke
464c3f048b DATACMNS-187 - Added getRevisionDate() to Revision.
Revision now exposes the revision date of the underlying metadata.
2012-07-16 10:53:18 +02:00
Oliver Gierke
4d326faa25 DATACMNS-193 - Introduced isQueryMethod(…) on RepositoryInformation. 2012-07-16 10:02:44 +02:00
Oliver Gierke
d9f293be54 DATACMNS-188 - Removed obsolete method from AbstractMappingContext. 2012-07-09 09:18:24 +02:00
Oliver Gierke
ebf8fdcbc4 DATACMNS-186 - Improved the way id properties are detected.
The id properties are now discovered by the BasicPersistentEntity during the call to addPersistentProperty(…). Beyond that the method rejects the id property if one was already set.
2012-06-22 14:24:00 +02:00
Oliver Gierke
f540306774 DATACMNS-185 - Expose AbstractMappingContext initialization.
Added initialize() method to AbstractMpapingContext to ease manual initialization.
2012-06-22 14:04:22 +02:00
Oliver Gierke
d441d95197 DATACMNS-58 - Added support for repository populators.
Added RepositoryPopulator abstraction and implementations based on Spring OXM Unmarshallers as well as Jackson. This allows arbitrary repositories being populated with data pulled from XML / JSON, no matter what store they are actually backed. The populator will eventually populate the repositories held in a Repositories instance. It can be used like this:

Repositories repositories = new Repositories(applicationContext);
ResourceReader reader = new JacksonResourceReader();

ResourceReaderRepositoryPopulator populator = new ResourceReaderRepositoryPopulator(reader);
populator.setResourceLocation("classpath*:data.json");
populator.populate(repositories);

The ResourceReader defines what technology shall be used to read the data from the file into objects. The ResourceReaderRepositoryPopulator uses the reader and can either get a set of Resource instances configured or is able to lookup resources using a location string. The actual Repositories instance captures all CrudRepository instances contained inside an ApplicationContext.

The populators can also be used from within XML configuration though the repository namespace elements shown below:

<repository:jackson-populator location="classpath:org/springframework/data/repository/init/data.json" />
		
<repository:unmarshaller-populator location="classpath:org/springframework/data/repository/init/data.xml" unmarshaller-ref="unmarshaller" />

Updated reference documentation accordingly.
2012-06-21 20:03:55 +02:00
Oliver Gierke
149cfa068c DATACMNS-182 - Added test case showing query method parsing works as expected. 2012-06-08 12:11:30 +02:00
Oliver Gierke
031129e461 DATACMNS-180 - Don't consider Java transient fields transient for persistence.
So far we have considered Java transient fields as transient through the isTransient() method on PersistentProperty. This resulted in the properties not being persisted eventually. We now consider all fields as non-transient by default as we actually have to persist them as the object cannot be re-created completely without doing so as the usage of the transient keyword might rely on the readObject(…) method inside the object which would actually reconstitute the transient field's state but we of course cannot call this method actually.
2012-06-06 12:33:17 +02:00
Oliver Gierke
e5c6af6b24 DATACMNS-179 - Defer adding initial entity set to AbstractMappingContext.
So far the domain classes to be added to the mapping context initially were added in afterPropertiesSet() of InitializingBean. This had the drawback that although the MappingContext is already set up properly the actual listeners of the events fired (e.g. index creating ones) might not have been set up properly. We list to the ContextRefreshedEvent indicating the entire ApplicationContext being set up completely. Thus all infrastructure components are set up properly and the timing issues doesn't exist anymore.
2012-06-04 12:24:10 +02:00
Oliver Gierke
1a24145ef9 DATACMNS-174 - Part.Type now exposes keywords. 2012-05-21 14:15:00 +02:00
Oliver Gierke
a7688b684c DATACMNS-172 - Improved handling of invalid PropertyPaths.
Introduced PropertyReferenceException to capture the invalid property and the base PropertyPath a property expression could be resolved into. Introduced getLeafProperty() to be able to access the leaf property of a property path being created.
2012-05-21 13:58:29 +02:00
Oliver Gierke
7673567a8c DATACMNS-171 - Added isQueryForEntity() method to QueryMethod.
isQueryForEntity() returns true if the QueryMethod returns either a single entity, a collection or Page of those.
2012-05-16 14:27:53 +02:00
Oliver Gierke
0f7231ec01 DATACMNS-170 - Fixed potential NullPointerException in ReflectionEntityInstantiator.
Moved null-check before the attempt to make the discovered id field accessible.
2012-05-07 12:53:54 +02:00
Oliver Gierke
e20938a3ae DATAMONGO-439 - Performance improvements in mapping subsystem.
Fixed minor performance problems discovered by the fix for DATAMONGO-439. We're now caching the information whether a constructor parameter is an enclosing class parameter. PersistentEntityParameterValueProvider is throwing an exception now if the parameter is not referring to a property of the entity (via the parameter name).
2012-05-03 17:25:51 +02:00
Oliver Gierke
aec655a499 DATACMNS-167 - Improved Iterable handling in TypeDiscoverer.
If a type implemented Iterable<…> it was currently treated as a collection which might cause inappropriate conversion in the mapping sub-system. We now consider types collection like if they're either Iterable directly or assignable to Collection.
2012-05-02 20:55:30 +02:00
Oliver Gierke
5b0cb1a572 DATACMNS-166 - Improved API in Repositories / RepositoryFactoryInformation.
Renamed methods in RepositoryMetadata to be consistent with EntityMetadata. Changed return type of RepositoryMetadata.getIdType() to Class<? extends Serializable>. Changed RepositoryFactoryInformation interface to expose RepositoryInformation rather than just the repository interface. Added exposing the QueryMethod instances as well. Adapter Repositories wrapper and it's clients accordingly.
2012-05-02 19:49:11 +02:00
Oliver Gierke
7f6c03d36a DATACMNS-143 - Removed deprecations in MappingContextEvent. 2012-04-27 19:10:24 +02:00
Oliver Gierke
8448573c3e DATACMNS-158 - Test case failing to reproduce the ticket.
Added test case to show that invalid properties containing numeric digits do not cause a stack overflow.
2012-04-23 18:04:38 +02:00
Oliver Gierke
ddea8eda8f DATACMNS-157 - Query method lookup now only returns most specific method for overridden methods.
Supposed you have a base repository interface declaring a method:

interface BaseRepository<T, ID extends Serializable> extends Repository<T, ID> {

  T myGenericMethod();
}

as well as a concrete repository redeclaring this method to annotate a query on it:

interface ConcreteRepository extends BaseRepository<User, Long> {

  @Query("…")
  User myGenericMethod()
}

Until now we both returned the intermediate method as well as the concrete one which might cause failures as in this case a query derivation would be attempted for the intermediate method which will fail for obvious reasons. The fix now starts with looking up the most specific method when iterating over the repository's methods which causes the intermediate method to be skipped in case it was overridden.
2012-04-20 13:55:49 +02:00
Oliver Gierke
06dc1e5dba DATACMNS-156 - Removed deprecated persistence package. 2012-04-20 13:20:14 +02:00
Oliver Gierke
ecf3592d1f DATACMNS-153 - Fixed class loading issue in SimpleEntityPathResolver.
The path class is loaded using the domain class' class loader instead of the one of SimpleEntityPathResolver.
2012-04-20 13:01:10 +02:00
Oliver Gierke
f1516a96aa DATACMNS-154 - Fixed query method detection when re-declararing CrudRepositoryMethods.
With the fix for DATACMNS-151 we apparently broke the generic parameter type matching for methods that carry the domain class type parameter as argument. We now inspect the bound and make sure we compare the name of it if it's a TypeVariable or use the plain parameter type if its not.
2012-04-19 12:45:33 +02:00
Oliver Gierke
81718ae373 DATACMNS-152 - Improved API in mapping subsystem.
PersistentProperty now exposes isEntity(). Mapping context now allows accessing a PersistentEntity referred to from a PersistentProperty. JavaDoc cleanups in MappingContext interface.
2012-04-14 13:27:50 +02:00
Oliver Gierke
67c8c53f5e DATACMNS-151 - Improve CrudRepository method signature generics.
Method signatures of save(…) methods in CrudRepository now return the concrete type passed in. This way subtypes can be persisted without casting the result back.

class Contact { … }
class Person extends Contact { … }

interface ContactRepository extends CrudRepository<Contact, Long> { … }

Before:

Person person = new Person();
person = (Person) repo.save(person);
         ^^^^^^^^

Now:

Person person = new Person();
person = repo.save(person);
2012-04-13 22:32:16 +02:00
Oliver Gierke
c158442dc7 DATACMNS-150 - Fixed potential ClassCastException in DomainClassConverter and -PropertyEditorRegistrar.
Introduced Repositories value object to easily access repository instances and EntityInformation objects registered in an ApplicationContext.
2012-04-13 21:18:07 +02:00
Oliver Gierke
aa12db22c0 DATACMNS-121 - Implement equals(…) and hashCode() of AbstractPersistentProperty.
Implemented equals(…) and hashCode() methods based on the field backing the property.
2012-04-11 21:00:03 +02:00
Oliver Gierke
f3d037ba7d DATACMNS-139 - Fixed potential StackOverflowException in PropertyPath.
When trying to access an inexistent property starting with an underscore (e.g. _id) PropertyPath.create(…) ran into a StackOverflowException. Changed the traversing regular expression to expect at least one capital letter for further traversals.
2012-04-11 18:18:58 +02:00
Oliver Gierke
109e7f903e DATACMNS-132 - Guard against untyped Maps and Collections in AbstractPersistentProperty.isEntity().
Just mentioned method threw a NullPointerException when the property was backed by an untyped Map or Collection as TypeInformation.getActualType() returns null in this case. Changed that to correctly return false.
2012-04-11 18:18:57 +02:00
Oliver Gierke
75c67f0b57 DATACMNS-124 - Removed accidentally committed code. 2012-04-11 18:18:43 +02:00
Oliver Gierke
a2e5cc439e DATACMNS-141 - Added Before and After as query parser keywords.
The query parser now supports After, IsAfter, Before and IsBefore as keywords. Added the Is* prefix to suitable keywords as well and refactored unit tests quite a bit to ease adding new keyword tests.
2012-04-09 17:39:16 +02:00
Oliver Gierke
b811fa3ea8 DATACMNS-124 - Added missing package-info.java files.
Polished JavaDocs. Polished MappingContextEvent and added deprecations to it to be cleaned up for 1.3.GA.
2012-04-04 17:39:30 +02:00