Branch: refs/heads/master
Home:
https://github.com/hibernate/hibernate-orm
Commit: 17d365ecf8965044227dc401f13fec86e3117e02
https://github.com/hibernate/hibernate-orm/commit/17d365ecf8965044227dc40...
Author: Jan-Willem Gmelig Meyling <jan-willem(a)youngmediaexperts.nl>
Date: 2020-09-04 (Fri, 04 Sep 2020)
Changed paths:
M hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java
M
hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EmbeddableTypeImpl.java
M
hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/spi/EmbeddedTypeDescriptor.java
M hibernate-core/src/test/java/org/hibernate/test/cut/CompositeUserTypeTest.java
Log Message:
-----------
HHH-14198 - Expose CompositeUserTypes through JPA Metamodel
Composite User Types work like regular Composite Types (like Embeddable) in HQL. However,
because they cannot be represented in the JPA metamodel, libraries like [GraphQL for
JPA](https://github.com/jcrygier/graphql-jpa) or
[
Blaze-Persistence](https://persistence.blazebit.com/) cannot fully utilize them. In order
to make the composite property names available to these libraries, it would be nice to
optionally expose these attributes as embedded attributes. This pull request aims to make
that change and makes it configurable through a custom setting.
Composite User Types are a common solution for mapping composite interfaces. A common
example is for example `Money` from the Java Money API (JSR-354), for which composite user
types are implemented in [
Jadira](http://jadira.sourceforge.net/usertype-userguide.html).
I know Composite User Types are currently not consiered in Hibernate 6.x. See also
[
this](https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm...
Zulip thread. I am not sure if Hibernate 6.x will even have multi column types, which I
presume would be a requirement to even introduce Composite User types back at some point.
Usually Embeddables are a much easier, suitable mechanism for composite user types. But
Embeddables are not always a viable alternative, because Embeddables require the type to
be subclassed (as an interface cannot be mapped, and the type may not solely comprise
fields that can be mapped to a simple basic type). To deal with this exact problem,
`MonetaryAmounts` are still mapped as composite user type. There also have been
suggestions to the JPA Spec to consider `AttributeConverters` for Embeddables for
pracitcally the same purpose (which I think is going to be a mess of an implementation).
See:
https://github.com/eclipse-ee4j/jpa-api/issues/105
Anyways, regardless of whether this gets integrated in 5.x, I don't expect it to be
integrated in 6.x unless we also reintroduce Composite User Types. I am willing to
contribute Composite User Types for 6.x if people see benefit in it and think it can be
done in the first place.