It is impossible to set Constraint.NO_CONSTRAINT for a @JoinColumn in @JoinTable. It will generate a FK no matter what. Error: Foreign key (FK3io8xbemymxv4bm5ccmh2ba8a:audience_sharing \[audience_group_id,provider_id])) must have same number of columns as the referenced primary key (audience_group \[audience_group_id]) I have tried all workaround but none works. The work arounds which applied the example below:
{code:java}@JoinColumn(name = "provider_id", referencedColumnName = "provider_id", foreignKey = @ForeignKey(value = Constraint.NO_CONSTRAINT){code}
{noformat}@JoinColumn(name = "provider_id", referencedColumnName = "provider_id", foreignKey = @ForeignKey(name = “none”, value = Constraint.NO_CONSTRAINT){noformat}
{noformat}@JoinTable( foreignKey = @ForeignKey(value = Constraint.NO_CONSTRAINT) ){noformat}
Example:
{code:java}@ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH}) @JoinTable( name = "sharing", joinColumns = { @JoinColumn(name = "audience_group_id", referencedColumnName = "audience_group_id"), @JoinColumn(name = "provider_id", referencedColumnName = "provider_id", foreignKey = @ForeignKey(value = Constraint.NO_CONSTRAINT)), }, inverseJoinColumns = @JoinColumn(name = "product_id") ) @JsonManagedReference private Set<Product> products = new HashSet<>(0);{code} |
|