]
Jeff MAURY updated JBIDE-26458:
-------------------------------
Fix Version/s: 4.16.0.AM1
(was: 4.15.0.Final)
Import Entities from DB with ManyToMany relationships doesn't
manage mappedBy
-----------------------------------------------------------------------------
Key: JBIDE-26458
URL:
https://issues.redhat.com/browse/JBIDE-26458
Project: Tools (JBoss Tools)
Issue Type: Bug
Components: hibernate
Affects Versions: 4.6.0.Final
Environment: Eclipse: Oxygen.3a Release (4.7.3a) Build id: 20180405-1200
DBMS: Sql Anywhere 17.0.9.4857
Annotations jdk 1.5+
Hibernate Version 5.2
Reporter: Matteo Barrese
Assignee: Koen Aers
Priority: Major
Fix For: 4.16.0.AM1
Import from entities tool does not correctly handle the bidirectional ManyToMany
relationships because in some cases it does not define mappedBy on one side.
example:
{code:java}
public class SecGroup implements java.io.Serializable {
....
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "SecGroupUser", schema = "dbm", joinColumns = {
@JoinColumn(name = "GroupId", nullable = false, updatable = false) },
inverseJoinColumns = {
@JoinColumn(name = "UserId", nullable = false, updatable = false) })
public Set<SsUsers> getSsUserses() {
return this.ssUserses;
}
....
}
public class SsUsers implements java.io.Serializable {
...
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "SecGroupUser", schema = "dbm", joinColumns = {
@JoinColumn(name = "UserId", nullable = false, updatable = false) },
inverseJoinColumns = {
@JoinColumn(name = "GroupId", nullable = false, updatable = false) })
public Set<SecGroup> getSecGroups() {
return this.secGroups;
}
...
}
{code}
It must be for example
{code:java}
public class SecGroup implements java.io.Serializable {
....
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "secGroups")
public Set<SsUsers> getSsUserses() {
return this.ssUserses;
}
....
}
public class SsUsers implements java.io.Serializable {
...
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "SecGroupUser", schema = "dbm", joinColumns = {
@JoinColumn(name = "UserId", nullable = false, updatable = false) },
inverseJoinColumns = {
@JoinColumn(name = "GroupId", nullable = false, updatable = false) })
public Set<SecGroup> getSecGroups() {
return this.secGroups;
}
...
}
{code}