Reputation: 5801
I've read through the JavaDoc and source code for PersistentProperty
, PersistentEntity
, BasicPersistentEntity
, etc. and am still not clear what these objects are.
Are these data objects? Or do they describe the data model?
If they are data objects, where's the data? For example, in PersistentProperty
I see the property's name and type, but no value.
Upvotes: 2
Views: 1741
Reputation: 83131
It's the Spring Data specific meta-model about types that we persist. They allow us to inspect the model classes independent from the backing store (JPA, MongoDB etc.) that have all different means to express what's an association, what an identifier property looks like etc.
This is made heavy use of in Spring Data REST to customize the representations rendered for the HTTP resources exported. Also, the store modules that implement their own store-to-object-mapping heavily inspect the domain model using these abstractions. In the JPA case, the implementation is basically backed by a JPA Metamodel
instance.
That said, the API's purpose is to provide the necessary metadata. It doesn't have to do with looking up values from objects in the first place. However, PersistentEntity
exposes both getPropertyAccessor(…)
and getIdentifierAccessor(…)
which can be used to obtain objects that allow property or identifier lookup for entity instances (see PersistentPropertyAccessor
and its implementations as well as IdentifierAccessor
).
Upvotes: 8