xa-datasource x creating tables in both database
lucianoborges Jul 3, 2012 4:16 PMHi all,
I'm trying create a two-phase commit application, but, when the JBoss starts the app creates the table on both databases.
My -ds.xml
<datasources> <xa-datasource> <jndi-name>PostgreSQLXA1</jndi-name> <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> <xa-datasource-property name="ServerName">localhost</xa-datasource-property> <xa-datasource-property name="PortNumber">5432</xa-datasource-property> <xa-datasource-property name="DatabaseName">bd1</xa-datasource-property> <xa-datasource-property name="User">postgres</xa-datasource-property> <xa-datasource-property name="Password">postgres</xa-datasource-property> <track-connection-by-tx></track-connection-by-tx> </xa-datasource> <xa-datasource> <jndi-name>PostgreSQLXA2</jndi-name> <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> <xa-datasource-property name="ServerName">localhost</xa-datasource-property> <xa-datasource-property name="PortNumber">5432</xa-datasource-property> <xa-datasource-property name="DatabaseName">bd2</xa-datasource-property> <xa-datasource-property name="User">postgres</xa-datasource-property> <xa-datasource-property name="Password">postgres</xa-datasource-property> <track-connection-by-tx></track-connection-by-tx> </xa-datasource> </datasources>
My persistence.xml
<persistence-unit name="database1-ds" transaction-type="JTA"> <jta-data-source>java:/PostgreSQLXA1</jta-data-source> <class>example.twophasecommit.domain.Book</class> <properties> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="false" /> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" /> </properties> </persistence-unit> <persistence-unit name="database1-ds" transaction-type="JTA"> <jta-data-source>java:/PostgreSQLXA2</jta-data-source> <class>example.twophasecommit.domain.BookSummary</class> <properties> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="false" /> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" /> </properties> </persistence-unit>
Is there something wrong?
Thanks,
Luciano