I also posted this thread in the Java Persistence (EntityManager and Annotations), Hibernate Search and Hibernate Validator forum:
Hello,
I'm currently refactoring my application to work with annotations but am encountering a problem when I have a class with 2 composite attributes in an embedded class:
Code:
@javax.persistence.Embeddable
@javax.persistence.MappedSuperclass
public class ArticleLocalization
implements org.dataisland.primitives.bean.Localization, Serializable {
...
private org.dataisland.primitives.datatype.Blob binaryContent;
@org.hibernate.annotations.Type(type="org.dataisland.primitives.hibernate.BlobHibernateType")
@javax.persistence.Embedded
@javax.persistence.AttributeOverrides( {
@javax.persistence.AttributeOverride(name="content", column = @javax.persistence.Column(name="BINARY_CONTENT_CONTENT") ),
@javax.persistence.AttributeOverride(name="contentType", column = @javax.persistence.Column(name="BINARY_CONTENT_CONTENTTYPE") ),
@javax.persistence.AttributeOverride(name="contentFileName", column = @javax.persistence.Column(name="BINARY_CONTENT_FILENAME") )
} )
public org.dataisland.primitives.datatype.Blob getBinaryContent() {
return this.binaryContent;
}
public void setBinaryContent(org.dataisland.primitives.datatype.Blob value) {
this.binaryContent = value;
}
private org.dataisland.primitives.datatype.Blob representation;
@org.hibernate.annotations.Type(type="org.dataisland.primitives.hibernate.BlobHibernateType")
@javax.persistence.Embedded
@javax.persistence.AttributeOverrides( {
@javax.persistence.AttributeOverride(name="content", column = @javax.persistence.Column(name="REPRESENTATION_CONTENT") ),
@javax.persistence.AttributeOverride(name="contentType", column = @javax.persistence.Column(name="REPRESENTATION_CONTENTTYPE") ),
@javax.persistence.AttributeOverride(name="contentFileName", column = @javax.persistence.Column(name="REPRESENTATION_FILENAME") )
} )
public org.dataisland.primitives.datatype.Blob getRepresentation() {
return this.representation;
}
public void setRepresentation(org.dataisland.primitives.datatype.Blob value) {
this.representation = value;
}
...
}
As you can see the class refers to two blobs which have different columns but (obviously) the same name.
Whey hibernate reads the mappings, I get this exception:
org.hibernate.MappingException: Repeated column in mapping for collection: ca.illi.article.closable.entities.ClosableArt
iclePlaceHolder.closableArticleSummaryLocalizations column: content
Does anyone know what I'm missing? If I remove one of the 2, it works fine. Seems to complain about columns being the same when the names are obviously different by my attribute overrides (?)
Any help would be greatly appreciated,
Thanks
François