hi everyone!
i'm having a 1:n relationship and tried nearly anything to make hibernate create right unique constraints. my last attempt was following code.
Code:
@AccessType("field")
@CollectionOfElements
@JoinTable(name = "PRODOFFERS_PRODOFFERPRICES", joinColumns = {
@JoinColumn(name="PRODUCT_OFFERING_ID", unique = true)
},
inverseJoinColumns = {
@JoinColumn(name="PRODUCTOFFERINGPRICE_ID", unique = false)
})
@OneToMany(cascade = CascadeType.ALL , fetch=FetchType.LAZY)
public List<ProductOfferingPrice> getProductOfferingPrice() {
if (productOfferingPrice == null) {
productOfferingPrice = new ArrayList<ProductOfferingPrice>();
}
return this.productOfferingPrice;
}
i assume that hibernate should create a single unique contraint onto PRODUCT_OFFERING_ID but it does not.
it always creates the productofferingprice_id as unique constraint as well, which is definitely wrong.
i also tried it without the joinColumn and inverseJoinColumn, no way out.
productofferingprice_id will always be generated.
what is wrong with hibernate or with me? ;)
thx in advance
best wishes
chris
PS: yes, i know i should use set instead, but it's generated...
PS: no need for additional code, it is unidirectional.
@edit: same ouput with HSQL and Oracle