Announcement Announcement Module
Collapse
No announcement yet.
HibernateItemWriter and hibernate4 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HibernateItemWriter and hibernate4

    Hi,
    I'm using spring-batch 2.1.8.RELEASE. We're upgrading to spring 3.1 and hibernate 4.1.6 and ran into an issue with HibernateItemWriter. I believe it's because HibernateItemWriter is using the hibernate3.HibernateTemplate class, which is incompatible with hibernate 4. Is this a known issue in HibernateItemWriter? Here's the stacktrace.
    Thanks

    java.lang.ClassCastException: org.springframework.orm.hibernate4.SessionHolder cannot be cast to org.springframework.orm.hibernate3.SessionHolder
    at org.springframework.orm.hibernate3.SessionFactoryU tils.doGetSession(SessionFactoryUtils.java:289)
    at org.springframework.orm.hibernate3.SessionFactoryU tils.getSession(SessionFactoryUtils.java:235)
    at org.springframework.orm.hibernate3.HibernateTempla te.getSession(HibernateTemplate.java:457)
    at org.springframework.orm.hibernate3.HibernateTempla te.doExecute(HibernateTemplate.java:393)
    at org.springframework.orm.hibernate3.HibernateTempla te.executeWithNativeSession(HibernateTemplate.java :374)
    at org.springframework.orm.hibernate3.HibernateTempla te.contains(HibernateTemplate.java:623)
    at org.springframework.batch.item.database.HibernateI temWriter.doWrite(HibernateItemWriter.java:117)
    at org.springframework.batch.item.database.HibernateI temWriter.write(HibernateItemWriter.java:94)
    at org.springframework.batch.core.step.item.SimpleChu nkProcessor.writeItems(SimpleChunkProcessor.java:1 71)
    at org.springframework.batch.core.step.item.FaultTole rantChunkProcessor.scan(FaultTolerantChunkProcesso r.java:523)
    at org.springframework.batch.core.step.item.FaultTole rantChunkProcessor.access$900(FaultTolerantChunkPr ocessor.java:49)
    at org.springframework.batch.core.step.item.FaultTole rantChunkProcessor$5.recover(FaultTolerantChunkPro cessor.java:393)
    at org.springframework.batch.retry.support.RetryTempl ate.handleRetryExhausted(RetryTemplate.java:420)
    at org.springframework.batch.retry.support.RetryTempl ate.doExecute(RetryTemplate.java:289)
    at org.springframework.batch.retry.support.RetryTempl ate.execute(RetryTemplate.java:187)
    at org.springframework.batch.core.step.item.BatchRetr yTemplate.execute(BatchRetryTemplate.java:213)
    at org.springframework.batch.core.step.item.FaultTole rantChunkProcessor.write(FaultTolerantChunkProcess or.java:402)
    at org.springframework.batch.core.step.item.SimpleChu nkProcessor.process(SimpleChunkProcessor.java:194)
    at org.springframework.batch.core.step.item.ChunkOrie ntedTasklet.execute(ChunkOrientedTasklet.java:74)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$ChunkTransactionCallback.doInTransaction(Tas kletStep.java:386)
    at org.springframework.transaction.support.Transactio nTemplate.execute(TransactionTemplate.java:130)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:264)
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe atCallback.java:76)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:367)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:214)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:250)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:195)
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(SimpleStepHandler.java:135)
    at org.springframework.batch.core.job.AbstractJob.han dleStep(AbstractJob.java:356)
    at org.springframework.batch.core.job.SimpleJob.doExe cute(SimpleJob.java:121)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:281)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:120)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:48)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:114)
    at org.springframework.batch.test.StepRunner.launchJo b(StepRunner.java:169)
    at org.springframework.batch.test.StepRunner.launchSt ep(StepRunner.java:158)
    at org.springframework.batch.test.JobLauncherTestUtil s.launchStep(JobLauncherTestUtils.java:238)

  • #2
    You might want to take this question to the Spring DATA forum?
    You could also diff hibernate4.SessionHolder source against hibernate3.SessionHolder source to see what the difference is?

    Jeff

    Comment


    • #3
      Looking at the code (https://github.com/SpringSource/spri...temWriter.java) HibernateItemWriter only works up to Hibernate3, yes.

      It should be fairly easy for you to fix that on your side. Reporting that as an issue would a good thing as well.

      Comment

      Working...
      X