\r
import org.hibernate.LockOptions;\r
import org.hibernate.Session;\r
+import org.hibernate.event.spi.MergeEvent;\r
\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
import eu.etaxonomy.cdm.model.common.ICdmBase;\r
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;\r
+import eu.etaxonomy.cdm.persistence.hibernate.PostMergeEntityListener;\r
import eu.etaxonomy.cdm.persistence.query.Grouping;\r
import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
\r
public List<T> merge(List<T> detachedObjects);\r
\r
/**\r
+ * This method allows for the possibility of returning the input transient\r
+ * entities instead of the merged persistent entity\r
+ *\r
+ * WARNING : This method should never be used when the objective of the merge\r
+ * is to attach to an existing session which is the standard use case.\r
+ * This method should only be used in the\r
+ * case of an external call which does not use hibernate sessions and is\r
+ * only interested in the entity as a POJO. Apart from the session information\r
+ * the only other difference between the transient and persisted object is in the case\r
+ * of new objects (id=0) where hibernate sets the id after commit. This id is copied\r
+ * over to the transient entity in {@link PostMergeEntityListener#onMerge(MergeEvent,Map)}\r
+ * making the two objects identical and allowing the transient object to be used further\r
+ * as a POJO\r
+ *\r
+ * @param detachedObjects\r
+ * @param returnTransientEntity\r
+ * @return\r
+ */\r
+ public List<T> merge(List<T> detachedObjects, boolean returnTransientEntity);\r
+\r
+ /**\r
+ * This method allows for the possibility of returning the input transient\r
+ * entity instead of the merged persistent entity\r
+ *\r
+ * WARNING : This method should never be used when the objective of the merge\r
+ * is to attach to an existing session which is the standard use case.\r
+ * This method should only be used in the\r
+ * case of an external call which does not use hibernate sessions and is\r
+ * only interested in the entity as a POJO. Apart from the session information\r
+ * the only other difference between the transient and persisted object is in the case\r
+ * of new objects (id=0) where hibernate sets the id after commit. This id is copied\r
+ * over to the transient entity in {@link PostMergeEntityListener#onMerge(MergeEvent,Map)}\r
+ * making the two objects identical and allowing the transient object to be used further\r
+ * as a POJO\r
+ *\r
* @param newInstance\r
* @param returnTransientEntity\r
* @return\r
\r
\r
\r
+\r
+\r
}
\ No newline at end of file
@Override\r
@Transactional(readOnly = false)\r
public List<T> merge(List<T> detachedObjects) {\r
+ return merge(detachedObjects, false);\r
+ }\r
+\r
+ @Override\r
+ @Transactional(readOnly = false)\r
+ public List<T> merge(List<T> detachedObjects, boolean returnTransientEntity) {\r
List<T> mergedObjects = new ArrayList<T>();\r
for(T obj : detachedObjects) {\r
- mergedObjects.add(dao.merge(obj));\r
+ mergedObjects.add(dao.merge(obj, returnTransientEntity));\r
}\r
return mergedObjects;\r
}\r