Announcement Announcement Module
Collapse
No announcement yet.
Setting Transaction Isolation for Hibernate + JPA + AS400/DB2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting Transaction Isolation for Hibernate + JPA + AS400/DB2

    Hello,

    I am currently struggling with the following:

    - I am using the nice JPA + Hibernate way to create generic DAO's, and wire all together with Spring (i am fairly new to Spring)

    - I am connecting to a AS400 DB2 database with jt400 toolkit.

    The problem lies in the fact that the database is not journaled. So, this means that I get the famous "[SQL7008] _TABLE_ in _SCHEMA_ not valid for operation" error when I try to update/insert/...

    The solution, when using a direct Hibernate programming, and without adding a journal to the db2, was to set the following properties:
    hibernate.connection.isolation=0

    Unfortunally, this is not honored when i try to do this in my Spring config... Any help to force this is very appriciated !!

    Abstract of my spring config XML:

    Code:
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
            <property name="driverClass" value="com.ibm.as400.access.AS400JDBCDriver" />
            <property name="jdbcUrl" value="jdbc:as400://myas400/" />
            <property name="user" value="myuser" />
            <property name="password" value="secret" />
            <property name="acquireIncrement" value="1" />
            <property name="idleConnectionTestPeriod" value="0" />
            <property name="maxIdleTime" value="0" />
            <property name="maxStatements" value="0" />
            <property name="maxPoolSize" value="10" />
            <property name="minPoolSize" value="1" />
            <property name="autoCommitOnClose" value="true" />
        </bean>
    
        <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="database" value="DB2" />
                    <property name="showSql" value="true" />
                    <property name="databasePlatform" value="org.hibernate.dialect.DB2400Dialect" />
                </bean>
            </property>
            <property name="jpaProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.DB2400Dialect</prop>
                    <prop key="hibernate.connection.isolation">0</prop>
                </props>
            </property>
        </bean>
    it seems that the
    Code:
    <prop key="hibernate.connection.isolation">0</prop>
    is ignored ?? Because it use to got picked up in traditional non-spring-non-jpa hibernate.cfg.xml !!!

    My persistence.xml is very bare:

    Code:
        <persistence-unit name="default" transaction-type="RESOURCE_LOCAL"> 
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
             
            <properties>
            	<property name="hibernate.connection.isolation" value="0"/>
            </properties>
        </persistence-unit>
    Also here, my cry for transaction isolation is not heard....

    I hope someone has a work around or good solution.

    Peter

  • #2
    I have this exact same issue.

    Comment


    • #3
      You need to journal your physical file on AS/400.

      Comment


      • #4
        I'm assuming that by journaling the file you didn't need to set the isolation level in the persistence.xml in the end however, did you ever get the override to work? I am setting the isolation level to 2 (READ_COMMITTED) but the SQL Performance Monitor on the iSeries has proved this did not work as it is remains at Read Stability (REPEATABLE_READ). Is there somewhere else I need to set READ_COMMITTED isolation level? I am using Hibernates JPA v3.3.1 and Spring Core 2.5.6.

        I have been struggling with this for some time and have posted on the Hibernate forum but no answers yet.

        Thanks in advance.

        Comment

        Working...
        X