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):
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))