Hi.
We are experiencing a strange behavior.
In my entity I have an embedded ID:
Code:
@EmbeddedId
@AttributeOverrides({@AttributeOverride(name = "id", column = @Column(name = "APP_ID", nullable = false))})
private Key key;
As you can see I am using @AttributeOverride since the Key is being used by other entities as well.
In my class I also have a reference to another entity:
Code:
@OneToOne(targetEntity = Association.class)
@JoinColumns
({
@JoinColumn(name = "APP_ID", referencedColumnName = "ADMIN_ID", insertable = false, updatable = false),
@JoinColumn(name = "CUSTOMER_ID", referencedColumnName = "CUSTOMER_ID", insertable = false, updatable = false)})
@AccessType(value = "property")
(there is no reference from the 'Association' class back)
When we try to retrieve the entity from the database (using Criteria), the left outer join being generated in order to fetch the 'Association' entity is wrong and mixed, the APP_ID is being compared to the CUSTOMER_ID and the CUSTOMER_ID to the ADMIN_ID:
Code:
on this_.CUSTOMER_ID=association2_.ADMIN_ID and this_.APP_ID=association2_.CUSTOMER_ID
should have been:
Code:
on this_.CUSTOMER_ID=association2_.CUSTOMER_ID and this_.APP_ID=association2_.ADMIN_ID
Does someone experience something similar? Is it because Hibernate does not support the mix of @AttributeOverride with @JoinColumn?
Thanks in advance,
Alon.