tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cole Ferrier <>
Subject Different behavior - Tomee Plus 7.0.3 vs Tomee plume 7.0.3 - JTA managed database connections
Date Tue, 25 Apr 2017 14:53:14 GMT
I have a need to be able to run a custom native sql command against the same
connection that is being used for a JPA query.

i have a JTAManaged datasource declared in my resources.xml, it is
referenced in a persistence.xml for JPA.

public class Foo {

	@PersistenceContext(unitName = "foo")
	private EntityManager entityManager;

	@Resource(name = "foo/myDatabase")
	private javax.sql.DataSource myDB;

	public DataObj getAll() {

		DataObj result = null;

		try {

			Connection connection = myDB.getConnection();

//actual alter session statement ommitted
			PreparedStatement ps = connection.prepareStatement("ALTER SESSION

			TypedQuery<DataObj> query =
entityManager.createNamedQuery("DataObj.findAll", DataObj.class);
			result = query.getSingleResult();

		} catch (Exception exception) {


		return result;

this code works in tomee Plus,  as this is a JTA managed transaction, i get
the same connection for both the direct database connection that is injected
and for the connection that is used by JPA.

If i deploy this to tomee plume (eclipse link).. i believe it is using two
different connections.

when i read:

it makes me think the behavior should be the same with eclipselink.

let me know what further information you would want. and how i can provide.

View this message in context:
Sent from the TomEE Users mailing list archive at

View raw message