Announcement Announcement Module
No announcement yet.
Transactional hibernate reader/writer with hibernate.connection.release_mode on_close Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactional hibernate reader/writer with hibernate.connection.release_mode on_close


    I'm just getting to know spring-batch and I hope someone can answer my question about why I need to set hibernate.connection.release_mode to value 'on_close'.

    my setup:

    	<batch:job id="MessageHandlerJob"
    		<batch:step id="MessageHandlerStep">
    			<batch:tasklet transaction-manager="hibernateTransactionManager">
    					isolation="DEFAULT" propagation="REQUIRED" />
    				<batch:chunk reader="MessageHandlerItemReader" writer="MessageHandlerItemWriter"
    					processor="MessageHandlerItemProcessor" commit-interval="1">
    	<bean id="hibernateTransactionManager"
    		<property name="sessionFactory">
          	  <seam:instance name="hibernateSessionFactory"/>
    	<bean id="MessageHandlerItemReader" class="MessageHandlerXItemReader" />
    	<bean id="MessageHandlerItemWriter" class="MessageHandlerXItemWriter" />
    When I run with no special configuration the scrollablecursor gets closed after each transaction (read chunck/commit-interval) and throws an JDBCException with connection closed when trying to get the next row of the cursor. However if i set hibernate.connection.release_mode to value 'on_close' it does not close my session and keeps this way my connection open.

    My problem lies in the fact that the Hibernate documentation states that 'on_close' should not be used anymore, and it is there for backwards compatibility only. That means I have made a mistake allong the line for needing it in the first place. It also states that with after_statement the session won't be closed when there is a scrollablecursor active. This however does not compute with the behavior I see and also does not compute with the implementation in the software. Atleast not where my debugging session leads to.

    Anyone have had this same problem? Are there other ways to avoid using on_close?