Wildfly and auto reconnect to the database

This working on Wildfly 8.1: <datasource jta=”true” jndi-name=”java:jboss/datasources/xxxdb” pool-name=”xxxxDB” enabled=”true” use-ccm=”false”> <connection-url>jdbc:mysql://localhost:3306/xxxdb?autoReconnect=true&amp;amp;useUnicode=true&amp;amp;characterEncoding=UTF-8</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <driver>mysql-connector-java-5.1.26-bin.jar</driver> <security> <user-name>xxxuser</user-name> <password>xxxpassword</password> </security> <validation> <check-valid-connection-sql>select 1</check-valid-connection-sql> <validate-on-match>false</validate-on-match> <background-validation>true</background-validation> <background-validation-millis>10000</background-validation-millis> </validation> <statement> <share-prepared-statements>false</share-prepared-statements> </statement> </datasource>

Detached Entity and Managed Entity

A detached entity is an entity whose state must not be reflected by the JPA provider. In other words, if you change its state (i.e. through setters methods) these changes will not be saved to the underlying database, as the JPA provider doesn’t have to “observe” such entities. If entity E1 is a managed entity … Read more

Difference between javax.inject.Singleton and javax.ejb.Singleton

I found a plausible explanation here: By default, javax.ejb.Singleton session beans are transactional (section 13.3.7 of the EJB 3.1 specification) and require acquisition of an exclusive lock for every business method invocation (sections 4.8.5.4 and 4.8.5.5). In contrast, a javax.inject.Singleton is not transactional and does not support container-managed concurrency (the major consequence being that no … Read more

Default EJB transaction mode for asynchronous methods?

Similar to an MDB the transaction is started by the container just before your @Asynchronous, @Schedule or @Timeout method (and applicable interceptors) is actually invoked and committed just after the method (and interceptors) completes. As per usual, the transaction propagates to all beans called in said method and all beans those beans call, recursively. Of … Read more