I am using Wildfly 8.1 and Postgres 9.2 with latest jdbc driver (non XA configured)
If I have a Session Bean like this:
@Stateless
public class MySessionBean {
@Resource(lookup="jdbc/mydb")
Datasource ds;
@PersistenceContext // defaults to datasource lookup name "jdbc/mydb"
EntityManager em;
public void method1() {
// will ds.getConnection() and
// the underlying connection used by em be the same?
}
}
Will ds.getConnection()
be the same underlying connection used by the EntityManager (em
) inside the method call of method1()
?
If they share the same jta-transaction, how is it that I don't need XA datasources and just regular one ? (assuming the lookup name for the datasource is also de default datasource for the EntityManager)
I can't find the corelation in the ejb 3.1 specs.
Besides the question I understand that I need to close the datasource connection myself but the transaction will be managed by the container (correct me if I am wrong)