12,7 → 12,9 |
import javax.persistence.OneToOne; |
import javax.persistence.PrimaryKeyJoinColumn; |
import javax.persistence.Table; |
import javax.persistence.Transient; |
import javax.persistence.UniqueConstraint; |
|
import org.hibernate.annotations.GenericGenerator; |
import org.hibernate.annotations.Parameter; |
|
21,76 → 23,91 |
*/ |
@Entity |
@Table(name = "relationship", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = { |
"term_from", "term_to", "type" })) |
public class Relationship implements java.io.Serializable { |
"term_from", "term_to", "type_id" })) |
public class Relationship implements java.io.Serializable |
{ |
private int objectId; |
|
private int objectId; |
private Term termByTermTo; |
private ObjectEntity object; |
private RelationshipType relationshipType; |
private Term termByTermFrom; |
@Transient |
private ObjectEntity object; |
|
public Relationship() { |
} |
private Term termFrom; |
private Term termTo; |
private RelationshipType relationshipType; |
|
public Relationship(Term termByTermTo, ObjectEntity object, |
RelationshipType relationshipType, Term termByTermFrom) { |
this.termByTermTo = termByTermTo; |
this.object = object; |
this.relationshipType = relationshipType; |
this.termByTermFrom = termByTermFrom; |
} |
public Relationship() |
{ |
} |
|
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "object")) |
@Id |
@GeneratedValue(generator = "generator") |
@Column(name = "object_id", unique = true, nullable = false) |
public int getObjectId() { |
return this.objectId; |
} |
public Relationship(Term termByTermTo, ObjectEntity object, |
RelationshipType relationshipType, Term termByTermFrom) |
{ |
this.termTo = termByTermTo; |
this.object = object; |
this.relationshipType = relationshipType; |
this.termFrom = termByTermFrom; |
} |
|
public void setObjectId(int objectId) { |
this.objectId = objectId; |
} |
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "object")) |
@Id |
@GeneratedValue(generator = "generator") |
@Column(name = "object_id", unique = true, nullable = false) |
public int getObjectId() |
{ |
return this.objectId; |
} |
|
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "term_to", nullable = false) |
public Term getTermByTermTo() { |
return this.termByTermTo; |
} |
public void setObjectId(int objectId) |
{ |
this.objectId = objectId; |
} |
|
public void setTermByTermTo(Term termByTermTo) { |
this.termByTermTo = termByTermTo; |
} |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "term_to", nullable = false) |
public Term getTermTo() |
{ |
return this.termTo; |
} |
|
@OneToOne(fetch = FetchType.LAZY) |
@PrimaryKeyJoinColumn |
public ObjectEntity getObject() { |
return this.object; |
} |
public void setTermTo(Term termByTermTo) |
{ |
this.termTo = termByTermTo; |
} |
|
public void setObject(ObjectEntity object) { |
this.object = object; |
} |
@OneToOne(fetch = FetchType.LAZY) |
@PrimaryKeyJoinColumn |
public ObjectEntity getObject() |
{ |
return this.object; |
} |
|
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "type", nullable = false) |
public RelationshipType getRelationshipType() { |
return this.relationshipType; |
} |
public void setObject(ObjectEntity object) |
{ |
this.object = object; |
} |
|
public void setRelationshipType(RelationshipType relationshipType) { |
this.relationshipType = relationshipType; |
} |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "type_id", nullable = false) |
public RelationshipType getRelationshipType() |
{ |
return this.relationshipType; |
} |
|
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "term_from", nullable = false) |
public Term getTermByTermFrom() { |
return this.termByTermFrom; |
} |
public void setRelationshipType(RelationshipType relationshipType) |
{ |
this.relationshipType = relationshipType; |
} |
|
public void setTermByTermFrom(Term termByTermFrom) { |
this.termByTermFrom = termByTermFrom; |
} |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "term_from", nullable = false) |
public Term getTermFrom() |
{ |
return this.termFrom; |
} |
|
public void setTermFrom(Term termByTermFrom) |
{ |
this.termFrom = termByTermFrom; |
} |
|
} |