Implement support for CompositeUserType and re-enable tests that make use of it #4824
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #3960
Citing from the migration guide:
The
CompositeUserTypeinterface was re-implemented to be able to model user types as proper embeddable types.A major difference to 5.x is the introduction of an "embeddable projection" that is used to determine the mapping structure.
Previously, a
CompositeUserTypehad to provide property names and types through dedicated accessor methods,but this was complicated for non-basic mappings and required quite some knowledge about Hibernate internals.
With 6.0 these methods are replaced with a method that returns an "embeddable projection" class.
The class is like a regular
@Embeddableclass and is used to determine the mapping structure for theCompositeUserType.Component values of a user type object are accessed by property index. The property index is 0-based and can be determined
by sorting the persistent attribute names lexicographically ascending and using the 0-based position as property index.
For example, the following component:
will assign property index 0 to
currencyand index 1 tovalue.Note that it is not possible anymore to use
@Columnsto specify the names of columns of a composite user type mapping.Since a
CompositeUserTypenow constructs a proper component, it is necessary to use the@AttributeOverrideannotation.