JPA @ManyToMany @ForeignKey name not used


stephane
 

Hi,
I'm trying to specify foreign-key names. This helps to reduce the effort on db schema comparison at the end of development, to prepare the schema upgrade script.
Actually it works very well on most relationships but I can't find the solution for JoinTables.

Here is an example of User class containing a collection of Group
@JoinTable(name = "iam_user_groups",
joinColumns =@JoinColumn(name = "user_id",referencedColumnName = "id",foreignKey = @ForeignKey(name="fk_user_groups" ))
,inverseJoinColumns = @JoinColumn(name = "group_id",referencedColumnName = "id",foreignKey = @ForeignKey(name="fk_groups_user"))
)
private Set<Group> groups = new HashSet<>();

The SchemaTool and DN doesn't seem to care about the foreignKey = @ForeignKey(name="fk_user_groups" and still generate iam_user_groups_fk1. 

Am I wrong in the mapping definition or is it not yet supported by Datanucleus. (I haven't seen restriction in the JPA specification.)

thanks,
--
Stephane

Join main@datanucleus.groups.io to automatically receive all group messages.