I am getting in touch with Seam intensively for days now and I'm already seriously addicted to this, I think, outstanding framework. But during experimenting I ran over a misbehaviour I cannot explain. The booking example shipped with Seam 1.0.1 GA doesn't correctly display the "Current Hotel Bookings" after a successful new booking. You need to login again to see the "Current Hotel Bookings" or book another hotel. But in latter case the recent booking isn't displayed either.
Are you *sure*, I find this difficult to believe.
Indeed, you're right! After deploying the original Seam 1.0.1 GA Booking Example I haven't encountered this problem again. So I tried to figure out what my problem is. The only thing I changed in the booking example was the booking-ds.xml which I defined to use a MySQL Database as datasource:
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>bookingDatasource</jndi-name> <connection-url>jdbc:mysql://localhost:3306/seam-booking</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>syscom</user-name> <password>ysy758</password> </local-tx-datasource> </datasources>
I am using MySQL 5.0.11 and the MySQL Connector 3.1.13. To sum it up: The misbehaviour does exist but only when using MySQL as datasource with the configuration above. And it must have to do something with transactions. Because after commenting out @TransactionAttribute(REQUIRES_NEW) in BookingListAction everything worked out again.
Then I checked if my database tables support transactions and they do by being InnoDB tables. I also checked my persistence.xml which defines the appropriate MySQLInnoDB dialect.
<persistence> <persistence-unit name="bookingDatabase"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/bookingDatasource</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="create"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/> <!-- These are the default for JBoss EJB3, but not for HEM: --> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> </properties> </persistence-unit> </persistence>
Is there maybe something missing related to transactions in my datasource definition or anywhere else?