Revision f4d35a72
Added by Andreas Kohlbecker almost 8 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/ClassificationDaoHibernateImpl.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase; |
28 | 28 |
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao; |
29 | 29 |
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao; |
30 |
import eu.etaxonomy.cdm.persistence.dto.ClassificationLookupDTO; |
|
30 | 31 |
|
31 | 32 |
/** |
32 | 33 |
* @author a.mueller |
... | ... | |
254 | 255 |
return persistentObject.getUuid(); |
255 | 256 |
} |
256 | 257 |
|
258 |
@Override |
|
259 |
public ClassificationLookupDTO classificationLookup(Classification classification) { |
|
260 |
|
|
261 |
ClassificationLookupDTO classificationLookupDTO = new ClassificationLookupDTO(classification); |
|
262 |
|
|
263 |
// only for debugging: |
|
264 |
// logger.setLevel(Level.TRACE); |
|
265 |
// Logger.getLogger("org.hibernate.SQL").setLevel(Level.DEBUG); |
|
266 |
|
|
267 |
String hql = "select t.id, n.rank, tp.id from TaxonNode as tn join tn.classification as c join tn.taxon as t join t.name as n " |
|
268 |
+ " left join tn.parent as tnp left join tnp.taxon as tp " |
|
269 |
+ " where c = :classification"; |
|
270 |
Query query = getSession().createQuery(hql); |
|
271 |
query.setParameter("classification", classification); |
|
272 |
@SuppressWarnings("unchecked") |
|
273 |
List<Object[]> result = query.list(); |
|
274 |
for(Object[] row : result) { |
|
275 |
Integer parentId = null; |
|
276 |
// if(row.length == 3) { // TODO check necessary? |
|
277 |
// parentId = (Integer) row[2]; |
|
278 |
// } |
|
279 |
classificationLookupDTO.add((Integer)row[0], (Rank)row[1], parentId); |
|
280 |
} |
|
281 |
|
|
282 |
return classificationLookupDTO ; |
|
283 |
} |
|
284 |
|
|
257 | 285 |
|
258 | 286 |
|
259 | 287 |
|
Also available in: Unified diff
attempt to reduce the overhead imposed by database access