-
Notifications
You must be signed in to change notification settings - Fork 682
DATACMNS-1699 - Add Embedded annotation. #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add core annotation for embedded object support and consider a potential prefix when using FieldNamingStrategies. The actual store specific implementation is done in the individual modules that make sure the mapping context provides means to detect embedded types and provide this information to the PersistentPropertyPathFactory now using PersistentEntities instead of the TypeInformation to construct mapped paths.
*/ | ||
default boolean isNullable() { | ||
|
||
return (isEmbedded() && findAnnotation(Embedded.class).onEmpty().equals(OnEmpty.USE_NULL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a property is not embedded, it is never nullable. If that is intended, it should be described in the documentation and the superfluous parens around the first &&
term should be removed.
Or the expression should get fixed. Also we should have tests for the not embedded case.
It'd be really nice if we could further customize this annotation with more parameters or pair it with another annotation to achieve the same effect from |
Embedded objects are conceptually stable regarding their property to field/column/… names. class Address {
String street, city;
}
class Order {
@Embedded(prefix = "shipping_")
Address shipping;
@Embedded(prefix = "billing_")
Address billing;
} Rendering fields @dcominottim care to elaborate how else you'd like to customize field names? |
Thanks for the reply, @mp911de. I had overlooked the 'prefix' param. It seems to work mostly fine for embedded objects that aggregate multiple properties (such as your class Company {
@Embedded
@AttributeOverride(
name = "companyName", // name of the target attribute
column = @Column(name = "CMP_NAME") // name that will be used for persistence
)
CompanyName name;
} Think of a scenario in which the company you work for has complex rules for data modeling and the data governance team may request you to use specific column/attribute names for certain tables/documents -- and they don't play well with Java/Spring Data attribute naming conventions. I am in such scenario right now and need to use On a separate note, does Spring Data fully support underscore in attribute names nowadays (as per your prefix example)? It didn't use to. Sorry if too obvious. #126 |
Thank you for open source contribution. The feature still be watched? |
Superseded by #2294. |
Add core annotation for embedded object support and consider a potential prefix when using
FieldNamingStrategies
.The actual store specific implementation is done in the individual modules that make sure the mapping context provides means to detect embedded types and provide this information to the
PersistentEntities
PersistentPropertyPathFactory
now usinginstead of the
TypeInformation` to construct mapped paths.