-
Notifications
You must be signed in to change notification settings - Fork 7
Hibernate-48 investigation #105
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
base: main
Are you sure you want to change the base?
Hibernate-48 investigation #105
Conversation
throw new FeatureNotSupportedException(format("%s is not supported", DynamicInsert.class.getSimpleName())); | ||
} | ||
metadata.visitRegisteredComponents(component -> { | ||
if (component.getStructName() != null && component.getProperties().isEmpty()) { |
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.
Does this work for empty @Embeddable
s that are not @Struct
? Hibernate ORM also omits storing them.
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.
no, the above only applies to STRUCT (STRUCT must have name so telling whether the struct name is present suffices).
If we want to enlarge the forbidding to any @Embeddable
, I think we simply drop the struct name checking above as below:
if (component.getProperties().isEmpty()) {
... ...
}
var holder = new StructHolder(); | ||
holder.id = 1; | ||
holder.emptyStruct = new EmptyStruct(); | ||
session.persist(holder); |
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.
What is the produced MQL result in this case?
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.
{"insert": "books", "documents": [{"author": {"firstName": null, "lastName": null}, "_id": 1}]}
From my understanding, @DynamicInsert
only covers an entity's root level fields. If the field is special type like STRUCT or array, it goes out of its scope how they are gonna to be persisted, as long as the field per se is non-null.
In our product, we use STRUCT to implement embedded doc and seeminly the same behavour should apply to the embeded doc; but this is our wishful thinking, for STRUCT is mainly used for SQL's User Defined Type. In traditional Hibernate design, all fields value should be provided to STRUCT (there is no analogy of @DynamicInsert
for STRUCT; again, @DynamicInsert
is only meant for entity class).
We need to straighten out some doubts for Hibernate-48. This DRAFT PR will contain various commits to showcase the validation results.