Project

General

Profile

« Previous | Next » 

Revision f9540b36

Added by Katja Luther almost 8 years ago

fix getUUIDAndTitleCache for references

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/reference/ReferenceDaoHibernateImpl.java
97 97
	public List<UuidAndTitleCache<Reference>> getUuidAndTitleCache(Integer limit, String pattern) {
98 98
		List<UuidAndTitleCache<Reference>> list = new ArrayList<UuidAndTitleCache<Reference>>();
99 99
		Session session = getSession();
100
		 Query query;
101
		if (pattern != null){
102
		    query = session.createQuery("SELECT " +"r.uuid, r.id, r.titleCache, ab.titleCache FROM " + type.getSimpleName() + " AS r LEFT OUTER JOIN r.authorship AS ab where r.titleCache like :pattern");
103
		}else{
104
		    query = session.createQuery("SELECT " +"r.uuid, r.id, r.titleCache, ab.titleCache FROM " + type.getSimpleName() + " AS r LEFT OUTER JOIN r.authorship AS ab ");//"select uuid, titleCache from " + type.getSimpleName());
105
		}
100 106

  
101
		Query query = session.createQuery("SELECT " +
102
				"r.uuid, r.id, r.titleCache, ab.titleCache FROM " + type.getSimpleName() + " AS r LEFT OUTER JOIN r.authorship AS ab ");//"select uuid, titleCache from " + type.getSimpleName());
103 107
		if (limit != null){
104 108
		    query.setMaxResults(limit);
105 109
		}
106

  
110
		if (pattern != null){
111
	          pattern = pattern + "%";
112
	          query.setParameter("pattern", pattern);
113
	    }
107 114
		@SuppressWarnings("unchecked")
108 115
        List<Object[]> result = query.list();
109 116

  

Also available in: Unified diff