Fixed DMP and User mappings

This commit is contained in:
Nikolaos Laskaris 2017-10-19 15:31:36 +03:00
parent 67caeffa54
commit 08a4abc9ff
3 changed files with 108 additions and 95 deletions

View File

@ -88,12 +88,21 @@ public class DMP implements Serializable {
private Set<Researcher> researchers;
// @OneToMany(fetch = FetchType.EAGER)
// @JoinTable(name="\"UserDMP\"",
// joinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")},
// inverseJoinColumns={@JoinColumn(name="user", referencedColumnName="\"ID\"")}
// )
// private Set<UserInfo> users;
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="\"UserDMP\"",
joinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")},
inverseJoinColumns={@JoinColumn(name="usr", referencedColumnName="id")}
)
private Set<UserInfo> users;
public Set<UserInfo> getUsers() {
return users;
}
public void setUsers(Set<UserInfo> users) {
this.users = users;
}
public UUID getId() {
@ -177,13 +186,7 @@ public class DMP implements Serializable {
}
// public Set<UserInfo> getUsers() {
// return users;
// }
//
// public void setUsers(Set<UserInfo> users) {
// this.users = users;
// }
public String toString() {
try {

View File

@ -1,76 +1,77 @@
//package entities;
//
//import java.io.Serializable;
//import java.util.UUID;
//
//import javax.persistence.Column;
//import javax.persistence.Entity;
//import javax.persistence.GeneratedValue;
//import javax.persistence.Id;
//import javax.persistence.Table;
//
//import org.hibernate.annotations.GenericGenerator;
//import org.hibernate.annotations.Type;
//
//import com.fasterxml.jackson.annotation.JsonIdentityInfo;
//import com.fasterxml.jackson.annotation.ObjectIdGenerators;
//
//@Entity
//@Table(name="\"UserInfo\"")
//@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="autoid")
//public class UserDMP implements Serializable{
//
// private static final long serialVersionUID = -4467370784003784660L;
//
//
// @Id
// @GeneratedValue
// @GenericGenerator(name = "uuid2", strategy = "uuid2")
// @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
// private UUID id;
//
// @Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
// @Column(name = "user", nullable = false)
// private UUID user;
//
// @Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
// @Column(name = "dmp", nullable = false)
// private UUID dmp;
//
// @Column(name = "role")
// private Integer role;
//
// public UUID getId() {
// return id;
// }
//
// public void setId(UUID id) {
// this.id = id;
// }
//
// public UUID getUser() {
// return user;
// }
//
// public void setUser(UUID user) {
// this.user = user;
// }
//
// public UUID getDmp() {
// return dmp;
// }
//
// public void setDmp(UUID dmp) {
// this.dmp = dmp;
// }
//
// public Integer getRole() {
// return role;
// }
//
// public void setRole(Integer role) {
// this.role = role;
// }
//
//
//}
package entities;
import java.io.Serializable;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name="\"UserDMP\"")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class UserDMP implements Serializable{
private static final long serialVersionUID = -4467370784003784660L;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
@Column(name = "usr", nullable = false)
private UUID usr;
@Type(type="org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
@Column(name = "dmp", nullable = false)
private UUID dmp;
@Column(name = "role")
private Integer role;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getUsr() {
return usr;
}
public void setUsr(UUID usr) {
this.usr = usr;
}
public UUID getDmp() {
return dmp;
}
public void setDmp(UUID dmp) {
this.dmp = dmp;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
}

View File

@ -73,13 +73,22 @@ public class UserInfo implements Serializable{
@Column(name = "additionalinfo", columnDefinition = "xml", nullable = true)
private String additionalinfo;
// @OneToMany(fetch = FetchType.EAGER)
// @JoinTable(name="\"UserDMP\"",
// joinColumns={@JoinColumn(name="user", referencedColumnName="\"ID\"")},
// inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
// )
// private Set<UserInfo> users;
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(name="\"UserDMP\"",
joinColumns={@JoinColumn(name="usr", referencedColumnName="id")},
inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
)
private Set<DMP> dmps;
public Set<DMP> getDmps() {
return dmps;
}
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
public UUID getId() {