Results 1 to 5 of 5

Thread: Hibernate with spring batch

  1. #1

    Default Hibernate with spring batch

    Hi All !

    I need to implement Spring Batch with Hibernate. My question is about transaction management.

    1. Spring Batch writes meta data to job repository using jdbc. (Atleast that is my finding. Please let me know if this is not correct)

    2. My ItemWriters would use hibernate to persist data that is read in ItemReaders.

    3. I will need to ensure that Spring Batch and Hibernate are running in one single transaction.

    It seems to me that I will need to define two transaction managers one for JDBC and another one for hibernate. How can I bring these two different transaction managers to participate in the same transaction ?

    any pointers are much appreciated ?

    Thanks

  2. #2
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    an HibernateTransactionManager should to the job, as long as the SessionFactory uses the same datasource as the JdbcTemplates.

  3. #3
    Join Date
    Dec 2010
    Posts
    19

    Default

    Quote Originally Posted by arno View Post
    an HibernateTransactionManager should to the job, as long as the SessionFactory uses the same datasource as the JdbcTemplates.
    in other words, if we make sure to use the same data source for the job-repository and hibernate configuration (session factory) then it should work. this way they both will share the same transaction manager and hence the scope...right?

    by the way what would be the solution if our spring batch database is different and database for business domain objects is different?

  4. #4

    Default

    My guess would be then to use a container managed transaction API such as JTA.

  5. #5
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    Quote Originally Posted by bleacherseat View Post
    My guess would be then to use a container managed transaction API such as JTA.
    right, you would need JTA. You don't have to use a full-blown application server though, you can use standalone JTA transaction managers like Atomikos or Bitronix Transaction Manager.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •