Announcement Announcement Module
Collapse
No announcement yet.
How to use HibernateItemWriter with Hibernate 4? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use HibernateItemWriter with Hibernate 4?

    Hi all,

    When using hibernate 3, the following code works:

    Code:
    	
             <bean id="ivsHibernateWriter"
    		class="org.springframework.batch.item.database.HibernateItemWriter">
    		<property name="hibernateTemplate" ref="hibernateTemplate"/>
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    	
    	<bean class="org.springframework.orm.hibernate3.HibernateTemplate" id="hibernateTemplate" >
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    After upgrading my test failes with this exception:

    Code:
    org.springframework.orm.hibernate4.SessionHolder cannot be cast to org.springframework.orm.hibernate3.SessionHolder
    I thought of changing the hibernateTemplate bean to be inline with hibernate 4, like so:

    Code:
    	
             <bean class="org.springframework.orm.hibernate4.HibernateTemplate" id="hibernateTemplate" >
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    However, this class does not exist.

    How should we work with Hibernate4 and spring Batch?

  • #2
    Looks like you don't, since this issue is still open: https://jira.springsource.org/browse/BATCH-1904

    Comment

    Working...
    X