* @see Contact#removeAddress(Address)
*/
protected void setContact(Contact newContact) {
- // Hibernate bidirectional cascade hack:
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
- if(this.contact == newContact) return;
- if (contact != null) {
- contact.addresses.remove(this);
- }
- if (newContact!= null) {
- newContact.addresses.add(this);
- }
this.contact = newContact;
}
* @see Address
*/
public void addAddress(Address address){
- address.setContact(this);
+ if (address != null){
+ address.setContact(this);
+ addresses.add(address);
+ }
}
/**
* Removes one element from the set of postal addresses of this contact.
* @see #getPerson()
* @see Person#removeInstitutionalMembership(InstitutionalMembership)
*/
- public void setPerson(Person newPerson) {
- // Hibernate bidirectional cascade hack:
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
- if(this.person == newPerson) return;
- if (person != null) {
- person.institutionalMemberships.remove(this);
- }
- if (newPerson!= null) {
- newPerson.institutionalMemberships.add(this);
- }
+ protected void setPerson(Person newPerson) {
this.person = newPerson;
}
public void addInstitutionalMembership(Institution institution, TimePeriod period, String department, String role){
//TODO to be implemented?
logger.warn("not yet fully implemented?");
- InstitutionalMembership ims = new InstitutionalMembership(institution, this, period, department, role);
+ InstitutionalMembership ims = new InstitutionalMembership(institution, this, period, department, role);
+ institutionalMemberships.add(ims);
}
/**
package eu.etaxonomy.cdm.model.common;
-
import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
super();
}
+//*************** MARKER **********************************************
+
+
@OneToMany(fetch=FetchType.LAZY)
@Cascade({CascadeType.SAVE_UPDATE})
public Set<Marker> getMarkers(){
return this.markers;
}
public void addMarker(Marker marker){
- marker.setMarkedObj(this);
+ if (marker != null){
+ marker.setMarkedObj(this);
+ markers.add(marker);
+ }
}
public void removeMarker(Marker marker){
marker.setMarkedObj(null);
this.markers = markers;
}
+//*************** ANNOTATIONS **********************************************
+
@OneToMany(fetch=FetchType.EAGER) //(mappedBy="AnnotatedObj")
@Cascade({CascadeType.SAVE_UPDATE})
public Set<Annotation> getAnnotations(){
return this.annotations;
}
public void addAnnotation(Annotation annotation){
- annotation.setAnnotatedObj(this);
+ if (annotation != null){
+ annotation.setAnnotatedObj(this);
+ annotations.add(annotation);
+ }
}
public void removeAnnotation(Annotation annotation){
annotation.setAnnotatedObj(null);
return annotatedObj;
}
protected void setAnnotatedObj(AnnotatableEntity newAnnotatedObj) {
- // Hibernate bidirectional cascade hack:
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
- if(this.annotatedObj == newAnnotatedObj) return;
- if (annotatedObj != null) {
- annotatedObj.annotations.remove(this);
- }
- if (newAnnotatedObj!= null) {
- newAnnotatedObj.annotations.add(this);
- }
this.annotatedObj = newAnnotatedObj;
}
return markedObj;
}
protected void setMarkedObj(AnnotatableEntity newMarkedObject) {
- // Hibernate bidirectional cascade hack:
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
- if(this.markedObj == newMarkedObject) return;
- if (markedObj != null) {
- markedObj.markers.remove(this);
- }
- if (newMarkedObject!= null) {
- newMarkedObject.markers.add(this);
- }
this.markedObj = newMarkedObject;
}
* @see #getRelationsToThisName()
* @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
*/
- @OneToMany(mappedBy="fromName", fetch= FetchType.EAGER)
+ @OneToMany(mappedBy="relatedFrom", fetch= FetchType.EAGER)
@Cascade({CascadeType.SAVE_UPDATE})
public Set<NameRelationship> getRelationsFromThisName() {
return relationsFromThisName;
* @see #getRelationsFromThisName()
* @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
*/
- @OneToMany(mappedBy="toName", fetch= FetchType.EAGER)
+ @OneToMany(mappedBy="relatedTo", fetch= FetchType.EAGER)
@Cascade({CascadeType.SAVE_UPDATE})
public Set<NameRelationship> getRelationsToThisName() {
return relationsToThisName;