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
 Assigned to: 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);






-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

Reply via email to