import org.apache.lucene.search.SortField;\r
import org.apache.lucene.util.Version;\r
import org.hibernate.Criteria;\r
+import org.hibernate.FlushMode;\r
import org.hibernate.HibernateException;\r
import org.hibernate.LockMode;\r
import org.hibernate.NonUniqueObjectException;\r
return results.get(0);\r
}\r
}\r
+ \r
+ @Override\r
+ public T findByUuidWithoutFlush(UUID uuid) throws DataAccessException{\r
+ Session session = getSession(); \r
+ FlushMode currentFlushMode = session.getFlushMode();\r
+ try { \r
+ // set flush mode to manual so that the session does not flush\r
+ // when before performing the query\r
+ session.setFlushMode(FlushMode.MANUAL);\r
+ Criteria crit = session.createCriteria(type);\r
+ crit.add(Restrictions.eq("uuid", uuid));\r
+ crit.addOrder(Order.desc("created"));\r
+ List<T> results = crit.list();\r
+ if (results.isEmpty()){\r
+ return null;\r
+ }else{\r
+ if(results.size() > 1){\r
+ logger.error("findByUuid() delivers more than one result for UUID: " + uuid);\r
+ }\r
+ return results.get(0);\r
+ }\r
+ } finally {\r
+ // set back the session flush mode \r
+ if(currentFlushMode != null) {\r
+ session.setFlushMode(currentFlushMode);\r
+ }\r
+ }\r
+ }\r
\r
@Override\r
public List<T> listByIds(Collection<Integer> ids, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws DataAccessException {\r