diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java
index ba2a6b3728235a5511fdfd0a0f6709a62e4964f4..36d88374613e9b96af5e5df5161ba21b9b6236c5 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package ch.systemsx.cisd.openbis.generic.shared.dto;
 
 import java.io.Serializable;
@@ -21,6 +22,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -42,12 +44,6 @@ import javax.persistence.Version;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Pattern;
 
-import ch.systemsx.cisd.openbis.generic.server.CommonServiceProvider;
-import ch.systemsx.cisd.openbis.generic.server.dataaccess.ISampleDAO;
-import ch.systemsx.cisd.openbis.generic.server.dataaccess.db.SampleRelationshipDAO;
-import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
-import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder;
-import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentityHolder;
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -66,6 +62,9 @@ import ch.rinn.restrictions.Private;
 import ch.systemsx.cisd.common.collection.UnmodifiableSetDecorator;
 import ch.systemsx.cisd.common.reflection.ModifiedShortPrefixToStringStyle;
 import ch.systemsx.cisd.openbis.generic.shared.IServer;
+import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
+import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder;
+import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentityHolder;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AttachmentHolderKind;
 import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.IdentifierHelper;
 import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier;
@@ -75,7 +74,7 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils;
 
 /**
  * <i>Persistent Entity</i> object of an entity 'sample'.
- *
+ * 
  * @author Christian Ribeaud
  */
 
@@ -130,26 +129,28 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co
 
     private String permId;
 
-    protected Set<SampleRelationshipPE> parentRelationships;
+    protected Set<SampleRelationshipPE> parentRelationships = new LinkedHashSet<SampleRelationshipPE>();
 
-    protected Set<SampleRelationshipPE> childRelationships;
+    protected Set<SampleRelationshipPE> childRelationships = new LinkedHashSet<SampleRelationshipPE>();
 
     private Set<MetaprojectAssignmentPE> metaprojectAssignments =
             new HashSet<MetaprojectAssignmentPE>();
 
-    @Transient
-    protected Set<SampleRelationshipPE> getSampleChildRelationships()
+    @OptimisticLock(excluded = true)
+    @OneToMany(fetch = FetchType.LAZY, mappedBy = "parentSample")
+    @Fetch(FetchMode.SUBSELECT)
+    private Set<SampleRelationshipPE> getSampleChildRelationships()
     {
-        if (childRelationships == null) {
-            if (id == null) {
-                childRelationships = new HashSet<>();
-            } else {
-                childRelationships = new HashSet<>(CommonServiceProvider.getDAOFactory().getSampleRelationshipDAO().listSampleChildren(List.of(id)));
-            }
-        }
         return childRelationships;
     }
 
+    // Required by Hibernate.
+    @SuppressWarnings("unused")
+    private void setSampleChildRelationships(final Set<SampleRelationshipPE> childRelationships)
+    {
+        this.childRelationships = childRelationships;
+    }
+
     @Transient
     public Set<SampleRelationshipPE> getChildRelationships()
     {
@@ -169,22 +170,23 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co
     {
         relationship.setParentSample(this);
         getSampleChildRelationships().add(relationship);
-        CommonServiceProvider.getDAOFactory().getSampleRelationshipDAO().persist(List.of(relationship));
     }
 
-    @Transient
-    protected Set<SampleRelationshipPE> getSampleParentRelationships()
+    @OptimisticLock(excluded = true)
+    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "childSample", orphanRemoval = true)
+    @Fetch(FetchMode.SUBSELECT)
+    private Set<SampleRelationshipPE> getSampleParentRelationships()
     {
-        if (parentRelationships == null) {
-            if (id == null) {
-                parentRelationships = new HashSet<>();
-            } else {
-                parentRelationships = new HashSet<>(CommonServiceProvider.getDAOFactory().getSampleRelationshipDAO().listSampleParents(List.of(id)));
-            }
-        }
         return parentRelationships;
     }
 
+    // Required by Hibernate.
+    @SuppressWarnings("unused")
+    private void setSampleParentRelationships(final Set<SampleRelationshipPE> parentRelationships)
+    {
+        this.parentRelationships = parentRelationships;
+    }
+
     @Transient
     public Set<SampleRelationshipPE> getParentRelationships()
     {
@@ -202,7 +204,6 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co
 
     public void setParentRelationships(final Set<SampleRelationshipPE> parentRelationships)
     {
-        CommonServiceProvider.getDAOFactory().getSampleRelationshipDAO().delete(getSampleParentRelationships());
         getSampleParentRelationships().clear();
         for (final SampleRelationshipPE sampleRelationship : parentRelationships)
         {
@@ -219,7 +220,6 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co
     {
         relationship.setChildSample(this);
         getSampleParentRelationships().add(relationship);
-        CommonServiceProvider.getDAOFactory().getSampleRelationshipDAO().persist(List.of(relationship));
     }
 
     public void removeParentRelationship(final SampleRelationshipPE relationship)
@@ -228,7 +228,6 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co
         relationship.getParentSample().getSampleChildRelationships().remove(relationship);
         relationship.setChildSample(null);
         relationship.setParentSample(null);
-        CommonServiceProvider.getDAOFactory().getSampleRelationshipDAO().delete(List.of(relationship));
     }
 
     /**
diff --git a/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/generic/SamplePENoDAO.java b/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/generic/SamplePENoDAO.java
index 7d513fc4a21233faa25cd951459485fa39b5bf90..2893ac32efdd33b3011afa83a3e4cfb93a745506 100644
--- a/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/generic/SamplePENoDAO.java
+++ b/server-application-server/sourceTest/java/ch/systemsx/cisd/openbis/generic/SamplePENoDAO.java
@@ -29,33 +29,33 @@ import java.util.Set;
  * This abstraction allows them to avoid using the introduced DAO behaving as naively as before introducing it.
  */
 public class SamplePENoDAO extends SamplePE {
-    @Override
-    protected Set<SampleRelationshipPE> getSampleChildRelationships() {
-        if (childRelationships == null) {
-            childRelationships = new HashSet<>();
-        }
-        return childRelationships;
-    }
-
-    @Override
-    protected Set<SampleRelationshipPE> getSampleParentRelationships() {
-        if(parentRelationships == null) {
-            parentRelationships = new HashSet<>();
-        }
-        return parentRelationships;
-    }
-
-    @Override
-    public void addChildRelationship(final SampleRelationshipPE relationship)
-    {
-        relationship.setParentSample(this);
-        getSampleChildRelationships().add(relationship);
-    }
-
-    @Override
-    public void addParentRelationship(final SampleRelationshipPE relationship)
-    {
-        relationship.setChildSample(this);
-        getSampleParentRelationships().add(relationship);
-    }
+//    @Override
+//    protected Set<SampleRelationshipPE> getSampleChildRelationships() {
+//        if (childRelationships == null) {
+//            childRelationships = new HashSet<>();
+//        }
+//        return childRelationships;
+//    }
+//
+//    @Override
+//    protected Set<SampleRelationshipPE> getSampleParentRelationships() {
+//        if(parentRelationships == null) {
+//            parentRelationships = new HashSet<>();
+//        }
+//        return parentRelationships;
+//    }
+//
+//    @Override
+//    public void addChildRelationship(final SampleRelationshipPE relationship)
+//    {
+//        relationship.setParentSample(this);
+//        getSampleChildRelationships().add(relationship);
+//    }
+//
+//    @Override
+//    public void addParentRelationship(final SampleRelationshipPE relationship)
+//    {
+//        relationship.setChildSample(this);
+//        getSampleParentRelationships().add(relationship);
+//    }
 }