Auto flush not work
kontomen2 Jan 27, 2011 11:03 AMHi,
I develop an application, based on Seam 2.2.0.GA, JPA over Hibernate and JBoss AS 5.1. In general, application skeleton was generated by seam-gen and the configuration was not changed so far. I use 4 XA datasources. My problem is that auto flush doesn't work, that is data are not flushed before commit. Of course, I use SMPC and 2 transactions per request approach (default in Seam) and I talk about first transaction. Using TRACE-level logs and breakpoints in proper lines in SessionImpl and PersistenceContexts classes, I already ensured that I have proper flush mode set on all EntityManagers (I tested AUTO and COMMIT). Transaction boundaries are also OK, if log doesn't lie ;). Probably important thing is that flushing works OK in general, for example used in session beans methods, where transaction boundaries are well defines by spec. But when I try to edit some entity (stored in conversation context) using direct binding its properties to JSF controls, changes are not flushed. When I invoke entityManager.flush() manually, on changing screen action, queries are flushed and then persisted thanks to commit before render response phase. All my SMPC are configured like this:
<persistence:managed-persistence-context auto-create="true" name="entityManager" persistence-unit-jndi-name="java:/my-EntityManagerFactory"/> <persistence:managed-persistence-context auto-create="true" name="entityManagerExternal" persistence-unit-jndi-name="java:/my-externalEntityManagerFactory"/> ...
my persistence.xml snippet:
<persistence-unit name="my-external"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/myExternalDatasource</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="jboss.entity.manager.factory.jndi.name" value="java:/my-externalEntityManagerFactory" /> </properties> </persistence-unit> ...
and all datasources defined in JBoss look like this:
<xa-datasource> <jndi-name>myExternalDatasource</jndi-name> <xa-datasource-property name="URL">jdbc:mysql://pandora:3306/java?autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8</xa-datasource-property> <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> <user-name>test</user-name> <password>test</password> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.hbm2ddl.auto">update</property> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name> <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name> <min-pool-size>1</min-pool-size> <max-pool-size>10</max-pool-size> <idle-timeout-minutes>10</idle-timeout-minutes> <metadata> <type-mapping>mySQL</type-mapping> </metadata> </xa-datasource> ...
Can you help me? I spent already 2 days trying to debug this issue and figure out what's going on here but basically have no idea.