Annotations of nested Embeddables are not processed when the Embeddables are in an ElementCollection.

Description

Annotations of nested Embeddables are not processed when the Embeddables are in an ElementCollection.

We have the following situation:

EmbeddableOne includes EmbeddableTwo includes EmbeddableThree.
Entity includes a single EmbeddableOne and a Set of EmbeddableOnes using ElementCollection.

Each Embeddable has it's own @Column and @Type Annotation:

When creating the tables Hibernate correctly uses the Annotations on the Properties to name the Columns and to set the Types of the Columns (using MySql):

create table EM_ENTITY (id bigint not null, birthdate date, name varchar(255), DATE_ONE date, NAME_ONE varchar(255), DATE_TWO date, NAME_TWO varchar(255), DATE_THREE date, NAME_THREE varchar(255), primary key (id))

When creating the table for the ElementCollection (without AttributeOverrides):

I get the following MappingException:
Caused by: org.hibernate.MappingException: Repeated column in mapping for collection: nestedEmbeddables.entity.EmEntity.manyOnes column: date
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:333)
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:358)
at org.hibernate.mapping.Collection.validate(Collection.java:319)
at org.hibernate.mapping.Set.validate(Set.java:27)
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:333)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:464)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:881)
... 26 more

although a different Column-Name is defined for each Embeddable.

When creating the table for the ElementCollection (with AttributeOverrides enabled) the MappingException is gone but the Date-Columns have a wrong Type (tinyblob instead of date):

create table EM_ENTITY_ONES (EmEntity_id bigint not null, OV_DATE_ONE date, OV_NAME_ONE varchar(255), OV_DATE_TWO tinyblob, OV_NAME_TWO varchar(255), OV_DATE_THREE tinyblob, OV_NAME_THREE varchar(255))

Attachments

1

Activity

Show:

Former user March 28, 2016 at 6:59 PM

Duplicates HHH-9089. Please see that jira for workaround.

Duplicate

Details

Assignee

Reporter

Components

Affects versions

Priority

Created March 27, 2016 at 3:29 PM
Updated December 3, 2024 at 9:28 AM
Resolved March 28, 2016 at 6:59 PM