[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6143) ElementCollection in Embeddable in Entity is ignored on merge

Andy Schlaikjer (JIRA) noreply at atlassian.com
Wed Apr 20 12:52:59 EDT 2011


ElementCollection in Embeddable in Entity is ignored on merge
-------------------------------------------------------------

                 Key: HHH-6143
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6143
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.6.3
         Environment: Hibernate EntityManager 3.6.3, HSQLDB 2.0.0
            Reporter: Andy Schlaikjer
         Attachments: merge-embedded-elementcollection.zip

*Overview*

When an {{@ElementCollection}} field {{ec}} is defined within an {{@Embeddable}} type {{C}}, and an {{@Embedded}} field {{em}} of type {{C}} is defined within an {{@Entity}} type {{E}}, if we create an {{E}} instance {{e}} and initialize {{e.em.ec}}, the value of {{e.em.ec}} is ignored on merge of {{e}}. Furthermore, the value is ignored even when {{ec}} has been annotated with {{@ElementCollection(fetch = FetchType.EAGER)}} and Hibernate's {{@Cascade(ALL)}}, and {{em}} has been annotated with {{@Cascade(ALL)}}.

Disclaimer: This use case may not be required by the JPA 2.0 spec (though it'd be nice to see support):

{quote}
Implementations are not required to support embedded objects that are mapped across more than one table (e.g., split across primary and secondary tables or multiple secondary tables).
{quote}

Note: This issue may be related to HHH-5187, HHH-4135.

*Steps to reproduce*

# Define {{@Embeddable}} type {{ContactInfo}} with {{@ElementCollection}} field {{emailAddresses}} of type {{List<String>}}.
# Define {{@Entity}} type {{Person}} with {{@Embedded}} field {{contactInfo}} of type {{ContactInfo}}.
# Create a new {{Person}} instance {{p1}} and initialize {{p1.contactInfo.emailAddresses}}.
# Use {{EntityManager}} to merge {{p1}}.
# Use {{EntityManager}} to find {{Person}} with id matching that of {{p1}}; Init {{p2}} with result.
# Compare {{p1}} and {{p2}}.

.

*Expected*

{{Person}} instances {{p1}} and {{p2}} are identical. Specifically, {{p2.contactInfo.emailAddresses}} should not be null, and its contents should match that of {{p1.contactInfo.emailAddresses}}.

*Observed*

{{Person}} instances {{p1}} and {{p2}} are not equal: {{p2.contactInfo.emailAddresses}} is null. On merge of {{p1}} Hibernate is ignoring non-null {{p1.contactInfo.emailAddresses}} property value. From the source code, it looks like the {{p1.contactInfo.emailAddresses}} property value is not being copied into the EntityManager's managed instance of {{p1}} on merge.

*Test case*

Please see the attached Maven project for full unit test.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list