Skip to content

Conversation

@beikov
Copy link
Member

@beikov beikov commented Feb 17, 2022

See #3960

Citing from the migration guide:

The CompositeUserType interface 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 CompositeUserType had 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 @Embeddable class and is used to determine the mapping structure for the CompositeUserType.

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:

public class MonetaryAmountEmbeddable {
	BigDecimal value;
	Currency currency;
}

will assign property index 0 to currency and index 1 to value.

Note that it is not possible anymore to use @Columns to specify the names of columns of a composite user type mapping.
Since a CompositeUserType now constructs a proper component, it is necessary to use the @AttributeOverride annotation.

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Feb 17, 2022

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [f2ac87f]

› This message was automatically generated.

@beikov beikov force-pushed the composite-user-type branch from f2ac87f to 07927a4 Compare February 25, 2022 10:00
@beikov beikov marked this pull request as ready for review February 25, 2022 10:00
@beikov beikov force-pushed the composite-user-type branch 2 times, most recently from 4e25075 to fa2c2e9 Compare February 25, 2022 12:10
@beikov beikov force-pushed the composite-user-type branch from fa2c2e9 to 98d4731 Compare February 25, 2022 14:36
@beikov beikov merged commit c520b48 into hibernate:main Feb 25, 2022
@beikov beikov deleted the composite-user-type branch February 25, 2022 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant