-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: lock when commit to multiple database
PostPosted: Mon Jan 14, 2008 4:31 am 
Newbie

Joined: Fri Sep 22, 2006 1:04 am
Posts: 5
lock occured in ejb transaction when commit to 2 different databases simultaneously.
as result: both database (data1 and data 2 are locked)

but separately or not in transaction is ok.

jboss 4.2.2, Hibernarte 3.2.5.ga


Code:
...
@Stateless
@Local(value = ProcessingLocal.class)
public class ProcessingBean implements ProcessingLocal
{
    @EJB(beanName = "Data1Bean", beanInterface = Data1Local.class)
    private Data1Local data1;
    @EJB(beanName = "Data2Bean", beanInterface = Data2Local.class)
    private Data2Local data2;

    public void test() throws Exception
    {
            Entity1 e1 = new Entity1();
            data1.merge(e1);

            Entity2 e2 = new Entity2();
            data2.merge(e2);
     }       
}



data-ds.xml
Code:
<datasources>

    <xa-datasource>
        <jndi-name>data1</jndi-name>
        <xa-datasource-class>com.informix.jdbcx.IfxXADataSource</xa-datasource-class>       
        <xa-datasource-property name="IfxIFXHOST">serv1</xa-datasource-property>       
        <xa-datasource-property name="IfxIFX_LOCK_MODE_WAIT">100</xa-datasource-property>
        <xa-datasource-property name="PortNumber">6666</xa-datasource-property>
        <xa-datasource-property name="DatabaseName">data1</xa-datasource-property>
        <xa-datasource-property name="ServerName">main</xa-datasource-property>
        <xa-datasource-property name="User">informix</xa-datasource-property>
        <xa-datasource-property name="Password">informix</xa-datasource-property>
        <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

        <min-pool-size>5</min-pool-size>
        <max-pool-size>1000</max-pool-size>
       
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter
        </exception-sorter-class-name>

        <metadata>
            <type-mapping>InformixDB</type-mapping>
        </metadata>

    </xa-datasource>

    <xa-datasource>
        <jndi-name>data2</jndi-name>
        <xa-datasource-class>com.informix.jdbcx.IfxXADataSource</xa-datasource-class>       
        <xa-datasource-property name="IfxIFXHOST">serv1</xa-datasource-property>
        <xa-datasource-property name="IfxIFX_LOCK_MODE_WAIT">100</xa-datasource-property>
        <xa-datasource-property name="PortNumber">6666</xa-datasource-property>
        <xa-datasource-property name="DatabaseName">data2</xa-datasource-property>
        <xa-datasource-property name="ServerName">main</xa-datasource-property>
        <xa-datasource-property name="User">informix</xa-datasource-property>
        <xa-datasource-property name="Password">informix</xa-datasource-property>
        <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

        <min-pool-size>5</min-pool-size>
        <max-pool-size>1000</max-pool-size>
       
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter
        </exception-sorter-class-name>

        <metadata>
            <type-mapping>InformixDB</type-mapping>
        </metadata>

    </xa-datasource>

</datasources>


in unit 1
persistence.xml
Code:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
          http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
        version="1.0">

    <persistence-unit name="data1" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:/data1</jta-data-source>       
        <properties>           
            <property name="hibernate.show_sql" value="false"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hibernate.transaction.factory_class" value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
        </properties>
    </persistence-unit>

</persistence>



in unit 2
persistence.xml
Code:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
          http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
        version="1.0">

    <persistence-unit name="data2" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:/data2</jta-data-source>       
        <properties>           
            <property name="hibernate.show_sql" value="false"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hibernate.transaction.factory_class" value="org.hibernate.ejb.transaction.JoinableCMTTransactionFactory"/>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
        </properties>
    </persistence-unit>

</persistence>

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 4:05 am 
Newbie

Joined: Fri Sep 22, 2006 1:04 am
Posts: 5
helped parametres:

<track-connection-by-tx/>
<isSameRM-override-value>false</isSameRM-override-value>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.