Announcement Announcement Module
Collapse
No announcement yet.
Integrating Spring batch with Hibernate 4.1.1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integrating Spring batch with Hibernate 4.1.1

    Hi,

    I am currently using Spring batch with Hibernate 3.6.9. I have created a job in spring batch as follows which works fine with hibernate version 3.6.9.
    <job id="searchJob" xmlns="http://www.springframework.org/schema/batch">
    <step id="searchStep">
    <tasklet>
    <chunk reader="searchItemReader"
    processor="searchItemProcessor"
    writer="searchItemWriter"
    commit-interval="1">
    </chunk>
    </tasklet>
    <end on="COMPLETED"/>
    <fail on="FAILED"/>
    </step>
    </job>

    I need to use Hibernate version 4.1.1 and for that I made changes to get session factory as follows.

    <bean id="searchItemReader" class="org.springframework.batch.item.database.Hib ernateCursorItemReader">
    <property name="sessionFactory" ref="sessionFactory"/>
    <property name="queryString">
    <value>
    from test
    </value>
    </property>
    <property name="useStatelessSession" value="false"/>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSes sionFactoryBean">
    <property name="configLocation" value="classpath:hibernate-cfg.xml"/>
    <property name="dataSource" ref="jobRepository-dataSource"/>
    </bean>
    <bean id="transactionManager"
    class="org.springframework.orm.hibernate4.Hibernat eTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    But now the HibernateCursorItemReader could not execute and spring batch job get failed each time. I could not find the reason.Is any dependency missing which I need to put? Is any one has idea of this issue?

    The pom.xml has the dependencies for spring and hibernate as follows:

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.1.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    <version>3.5.6-Final</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.batch</groupId>
    <artifactId>spring-batch-core</artifactId>
    <version>2.1.8.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.batch</groupId>
    <artifactId>spring-batch-infrastructure</artifactId>
    <version>2.1.8.RELEASE</version>
    </dependency>

    Thanks in advance.
    Last edited by springquery; Apr 16th, 2012, 06:48 AM.
Working...
X