From: Manoj A. (JIRA) <ji...@an...> - 2005-12-28 23:38:42
|
[ http://jira.andromda.org/browse/HIB-158?page=comments#action_12376 ] Manoj Agrawal commented on HIB-158: ----------------------------------- Just a correction, instead of - final Object entity = this.getHibernateTemplate().get(${entity.fullyQualifiedEntityName}.class, $identifier.name); It should be final Object entity = this.getHibernateTemplate().get(${entity.fullyQualifiedEntityImplementationName}.class, $identifier.name); > Use get() instead of find() w/HQL for DAO load() > ------------------------------------------------ > > Key: HIB-158 > URL: http://jira.andromda.org/browse/HIB-158 > Project: Hibernate Cartridge > Type: Improvement > Versions: 3.1 > Reporter: Jason Dillon > Assignee: Carlos Cuenca > > This relates to: http://galaxy.andromda.org/forum/viewtopic.php?p=8200 > ---- > he Spring dao that is generated for the entity has load method which uses HQL for loading the entity. Would this implementation take into effect the lazy loading parameters in the hibernate config files? As far as hibernate documentation says, the lazy loading will not be considered when using HQL. > Why not just use the get(BusinessObject.class, id) implementation? > ---- > To fix, in template/sprint/hibernate/SpringHibernateDaoBase.vsl change: > final java.util.List list = this.getHibernateTemplate().find( > "from $entity.fullyQualifiedEntityName as entity where entity.$identifier.name = ?", $argument); > final Object entity = list != null && !list.isEmpty() ? list.iterator().next() : null; > to: > final Object entity = this.getHibernateTemplate().get(${entity.fullyQualifiedEntityName}.class, $identifier.name); |