[hibernate-issues] [JIRA] (HHH-14063) @Convert annotation on Embeddable nested in Embeddable in an ElementCollection does not work (or: ambiguous default access strategy? )

Stefan Ocke (JIRA) jira at hibernate.atlassian.net
Tue Jun 9 09:16:22 EDT 2020


Stefan Ocke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aa6f955d5-ad1a-4a8f-ad2f-49abbfc72b94 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWM0MGFmMmU3OTM2NDQ0YmJjYWI4ZDYzOTZkMjE3MmQiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14063?atlOrigin=eyJpIjoiOWM0MGFmMmU3OTM2NDQ0YmJjYWI4ZDYzOTZkMjE3MmQiLCJwIjoiaiJ9 ) HHH-14063 ( https://hibernate.atlassian.net/browse/HHH-14063?atlOrigin=eyJpIjoiOWM0MGFmMmU3OTM2NDQ0YmJjYWI4ZDYzOTZkMjE3MmQiLCJwIjoiaiJ9 ) @Convert annotation on Embeddable nested in Embeddable in an ElementCollection does not work (or: ambiguous default access strategy? ) ( https://hibernate.atlassian.net/browse/HHH-14063?atlOrigin=eyJpIjoiOWM0MGFmMmU3OTM2NDQ0YmJjYWI4ZDYzOTZkMjE3MmQiLCJwIjoiaiJ9 )

Change By: Stefan Ocke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aa6f955d5-ad1a-4a8f-ad2f-49abbfc72b94 )

I have re-tested  [HHH-10857] with Hibernate 5.4.15:

* For “simple” Embeddables (directly used in the Entity as @Embedded), @Convert annotation works.

* For Embeddables in ElementCollections, @Convert annotation also works now. So, the original issue [HHH-10857] seems to be fixed.

* However, in the following situation, @Convert is still ignored:
** I have an Element Collection of an Embeddable OuterEmbeddable.
**  “OuterEmbeddable“ contains another Embeddable called InnerEmeddable
** Within InnerEmeddable I use @Convert on basic fields. But it is ignored.

My current workaround is to use @Convert one level higher:

{code:java}@Embeddable
class OuterEmbeddable{
@Convert(converter = MyConverter.class, attributeName = "theFieldToConvert")
InnerEmeddable theInnerEmbeddable
}{code}

My testcase reveals revealed some more details:

* *It works if I enforce field level access on the inner embeddable by “@Access(AccessType.FIELD)“*
* The error occurs (but only on the inner embeddable, as described above) if I do not enforce field level access.

So I assume, Hibernate for some reasons detects field level access on the outer embeddable but property level access on the inner embeddable.

And property level access leads to ignoring the Convert annotation on the inner embeddable.

At [https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#access-embeddable-types|https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#access-embeddable-types] we have:

{quote}Because embeddables are managed by their owning entities, the access strategy is therefore inherited from the entity too. This applies to both simple embeddable types as well as for collection of embeddables.{quote}

It seems, with an embeddable within an embeddable, I have a corner case where access strategy is not well-defined?

( https://hibernate.atlassian.net/browse/HHH-14063#add-comment?atlOrigin=eyJpIjoiOWM0MGFmMmU3OTM2NDQ0YmJjYWI4ZDYzOTZkMjE3MmQiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14063#add-comment?atlOrigin=eyJpIjoiOWM0MGFmMmU3OTM2NDQ0YmJjYWI4ZDYzOTZkMjE3MmQiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100128- sha1:85a81c0 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200609/3e880a0f/attachment.html 


More information about the hibernate-issues mailing list