Announcement Announcement Module
Collapse
No announcement yet.
HibernateTemplate loadAll() fails Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HibernateTemplate loadAll() fails

    Hi,

    I have an issue with the HibernateTemplate.
    It returns an empty List when I use loadAll().

    In my DAO, which is extending from HibernateDaoSupport I have the following method:

    Code:
    	
    @SuppressWarnings("unchecked")
    public List<AttachmentType> getAllAttachmentTypes() {
    		
    	List<AttachmentType> types = getHibernateTemplate().loadAll(AttachmentType.class);
    	return types;
    }
    My Spring configuration files is configured like this:

    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource" ref="dataSource" />
    		<property name="mappingResources">
    			<list>
    <value>com/base/ju/kafka/props/hibernate/AttachmentType.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
    				<prop key="hibernate.show_sql">true</prop>
    				<prop key="hibernate.use_outer_join">true</prop>
    			</props>
    		</property>
    	</bean>
    The hibernate config and the object:

    Code:
    Properties of the AttachmentType object: (getters and setters are not listed here)
    	private Long id;
    	private String typeName;
    	private String typeDescription;
    	private Date modificationDate;
    	private Date creationDate;
    
    Hibernate mapping that is mapped to this object:
    
    <hibernate-mapping>
      <class name="com.bla.bla.bla.request.model.AttachmentType" table="JU_ATTACHMENT_TYPE_TBL" lazy="true">
      	<id name="id" column="JU_ATT_TYPE_ID" />
      	<property name="typeName" column="TYPE_NM"/>
      	<property name="typeDescription" column="TYPE_DESC"/>
      	<property name="modificationDate" column="MODIFICATION_DT"/>
      	<property name="creationDate" column="CREATION_DT"/>
      </class>
    </hibernate-mapping>
    Logging:
    Code:
    1373045 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager  - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@1c4bcda]
    1373045 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Initializing transaction synchronization
    1373045 [main] DEBUG org.springframework.transaction.interceptor.TransactionInterceptor  - Getting transaction for [com.base.ju.kafka.request.dao.RequestDAO.getAllAttachmentTypes]
    1373045 [main] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils  - Opening Hibernate Session
    1373045 [main] DEBUG org.hibernate.impl.SessionImpl  - opened session at timestamp: 11890871954
    1373045 [main] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils  - Registering Spring transaction synchronization for new Hibernate Session
    1373045 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Bound value [org.springframework.orm.hibernate3.SessionHolder@14aa6c3] for key [org.hibernate.impl.SessionFactoryImpl@1e758ca] to thread [main]
    1373045 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@14aa6c3] for key [org.hibernate.impl.SessionFactoryImpl@1e758ca] bound to thread [main]
    1373045 [main] DEBUG org.springframework.orm.hibernate3.HibernateTemplate  - Found thread-bound Session for HibernateTemplate
    1373045 [main] DEBUG org.springframework.transaction.support.TransactionSynchronizationManager  - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@14aa6c3] for key [org.hibernate.impl.SessionFactoryImpl@1e758ca] bound to thread [main]
    1373045 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    1373045 [main] DEBUG org.hibernate.jdbc.ConnectionManager  - opening JDBC connection
    1373045 [main] DEBUG org.hibernate.SQL  - select this_.JU_ATT_TYPE_ID as JU1_0_0_, this_.TYPE_NM as TYPE2_0_0_, this_.TYPE_DESC as TYPE3_0_0_, this_.MODIFICATION_DT as MODIFICA4_0_0_, this_.CREATION_DT as CREATION5_0_0_ from JU_ATTACHMENT_TYPE_TBL this_
    Hibernate: select this_.JU_ATT_TYPE_ID as JU1_0_0_, this_.TYPE_NM as TYPE2_0_0_, this_.TYPE_DESC as TYPE3_0_0_, this_.MODIFICATION_DT as MODIFICA4_0_0_, this_.CREATION_DT as CREATION5_0_0_ from JU_ATTACHMENT_TYPE_TBL this_
    1373060 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to open ResultSet (open ResultSets: 0, globally: 0)
    1373060 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close ResultSet (open ResultSets: 1, globally: 1)
    1373060 [main] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    1373060 [main] DEBUG org.hibernate.engine.StatefulPersistenceContext  - initializing non-lazy collections
    1373060 [main] DEBUG org.hibernate.jdbc.ConnectionManager  - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    1373060 [main] DEBUG org.springframework.orm.hibernate3.HibernateTemplate  - Not closing pre-bound Hibernate Session after HibernateTemplate
    According the logs, the query is executed fine.
    When I test the query in a DB client, it is returning a resultset of size 8.
    But while debugging the code, it returns an empty list.

    Can somebody help me.
    I'm searching for days now and can't find anything.

    Thanks

  • #2
    Use Spy jdbc driver to find out exactly what happens at the jdbc level, Hibernate logging is not enough.

    http://zer0.free.fr/craftsman/spy.php

    Comment

    Working...
    X