Quote:
I know that adding the following to persistence.xml resolves my issue, but I'm not about to make a change like this for an isolated case:
Actually, if WebLogic works fine with AFTER_TRANSACTION,
you are better off using that instead of AFTER_STATEMENT.
As for your issue, closing the Connection means returning the Connection to the XA pool. However, the XA pool can't assign the released Connection since your transaction is still not committed or rolled back. That's how JTA Transaction Managers works.
If this is an issue, it must be either the WebLogic or the way the DataSource is configured in WebLogic.
Now, back to your code:
Code:
session.doWork( new Work() {
public void execute(Connection connection) throws SQLException {
...//brevity
ResultSet rs = pStmt.executeQuery();
while (rs.next()) { // Exception here on 2nd loop b/c of the 1st iteration's Session.get
...//do some work
Entity ent = session.get(Entity.class, someId);
...//do some more
}
...//close up JDBC resources
}
});
The reason you are inside a doWork block is to operate on the JDBC Connection, so why do you call the Session?
Your code looks like you are doing an application-level Nested-Loop joining algorithm.
So, you can split those in two. Do the JDBC doWork and return a list of DTOs or whatever you need. Do the processing of DTO + Hibernate calls afterward, outside of the doWork block.