If an entity has a Java Map attribute (key-value) whose value type is non primitive (ie an Object other than String, Long, etc.), then in the auto-generated DDL there is an improper "unique" constraint on the value column of the association table corresponding to the Java Map.
Example (simplified) :
@Entity
public class Customer {
@OneToMany
@JoinTable(name="customer_order")
@MapKeyColumn(name = "somekey", length = 10)
private Map<String,Order> orders;
}
In this example, the association table is "customer_order"; in the auto-generated DDL, the "customer_order" table has 3 columns (so far so good): customer_id, somekey, and order_id
Problem: there is an "unique" constraint on the order_id column.
If in the Java above example we replace the "Order" type by "String" (ie private Map<String,String> orders), then there is no unique constraint on the order column of the association table.
|