package eu.etaxonomy.cdm.model.common;
+import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
+import javax.persistence.JoinTable;
+import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
+import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
-@Entity
-@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
-public abstract class RelationshipTermBase extends EnumeratedTermBase {
+@MappedSuperclass
+public abstract class RelationshipTermBase extends OrderedTermBase {
static Logger logger = Logger.getLogger(RelationshipTermBase.class);
private boolean symmetric;
private boolean transitive;
- private Set<Representation> inverseRepresentations;
+ private Set<Representation> inverseRepresentations = new HashSet();
- public RelationshipTermBase(String term, String label, Enumeration enumeration, boolean symmetric, boolean transitive) {
- super(term, label, enumeration);
+ public RelationshipTermBase() {
+ super();
+ }
+ public RelationshipTermBase(String term, String label, boolean symmetric, boolean transitive) {
+ super(term, label);
setSymmetric(symmetric);
setTransitive(transitive);
}
@OneToMany
+ @JoinTable(name="RelationshipTermBase_inverseRepresentation")
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
public Set<Representation> getInverseRepresentations() {
return inverseRepresentations;
Set<Representation> inverseRepresentations) {
this.inverseRepresentations = inverseRepresentations;
}
- public void addRepresentation(Representation representation) {
- this.inverseRepresentations.add(representation);
+ public void addInverseRepresentation(Representation inverseRepresentation) {
+ this.inverseRepresentations.add(inverseRepresentation);
+ }
+ public void removeInverseRepresentation(Representation inverseRepresentation) {
+ this.inverseRepresentations.remove(inverseRepresentation);
}
- public void removeRepresentation(Representation representation) {
- this.inverseRepresentations.remove(representation);
+ public void addRepresentation(Representation representation, Representation inverseRepresentation) {
+ this.addRepresentation(representation);
+ this.addInverseRepresentation(inverseRepresentation);
}
@Transient