]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.hibernate/src/main/java/org/argeo/slc/hibernate/structure/tree/TreeSPathDaoHibernate.java
1e120632c042833e6f3c72b9d4fb8fc1965976a8
1 package org
.argeo
.slc
.hibernate
.structure
.tree
;
5 import org
.springframework
.orm
.hibernate3
.support
.HibernateDaoSupport
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
10 import org
.argeo
.slc
.core
.structure
.tree
.TreeSPath
;
11 import org
.argeo
.slc
.dao
.structure
.tree
.TreeSPathDao
;
14 * The Hibernate implementation for tree-based result of the test result dao.
18 public class TreeSPathDaoHibernate
extends HibernateDaoSupport
implements
21 private static Log log
= LogFactory
.getLog(TreeSPathDaoHibernate
.class);
23 public void create(TreeSPath path
) {
27 private void createImpl(TreeSPath path
) {
28 if (path
.getParent() != null) {
29 TreeSPath parent
= getTreeSPath(path
.getParent()
30 .getAsUniqueString());
32 createImpl(path
.getParent());
35 getHibernateTemplate().save(path
);
36 if (log
.isTraceEnabled())
37 log
.trace("Saved TreeSPath " + path
.getAsUniqueString());
40 public TreeSPath
getTreeSPath(String pathString
) {
41 List
<?
> list
= getHibernateTemplate().find(
42 "from TreeSPath where asUniqueString=?", pathString
);
43 if (list
.size() == 0) {
46 return (TreeSPath
) list
.get(0);
50 public TreeSPath
getOrCreate(TreeSPath pathTransient
) {
51 TreeSPath path
= getTreeSPath(pathTransient
.getAsUniqueString());
55 create(pathTransient
);
57 return getTreeSPath(pathTransient
.getAsUniqueString());