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

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

    Hi,

    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:

    Code:
    	<batch:job id="MessageHandlerJob"
    		job-repository="jobRepository">
    		<batch:step id="MessageHandlerStep">
    			<batch:tasklet transaction-manager="hibernateTransactionManager">
    				<batch:transaction-attributes
    					isolation="DEFAULT" propagation="REQUIRED" />
    				<batch:chunk reader="MessageHandlerItemReader" writer="MessageHandlerItemWriter"
    					processor="MessageHandlerItemProcessor" commit-interval="1">
    				</batch:chunk>
    			</batch:tasklet>
    		</batch:step>
    	</batch:job>
    
    	<bean id="hibernateTransactionManager"
    		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory">
          	  <seam:instance name="hibernateSessionFactory"/>
        	</property>	
    	</bean>	
    
    	<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?

    Regards,

    Hans
Working...
X