|
Hi Steve, thanks for coming back on that issue. I am my self not trying to argue but interpreted the lack of feedback for a while.
I concede that the various scenarios attached here can be confusing and not very clear to what they show or prove. As a summary:
Initial problem A database constraint violation occurring in JPA code implemented by Hibernate JPA version 4 gets reported as “rollback exception” on Weblogic with a JTA transaction manager.
Test code In the latest attached sample test.hhh9888_4.zip , a JAX-RS resource creates a customer using JPA or JDBC:
@Path("jpaFail")
@GET
@Produces("text/plain")
public Response testJpaFail() {
return createCustomerWithId(100, this.saveWithJpaOperation);
}
@Path("fail")
@GET
@Produces("text/plain")
public Response testFail() {
return createCustomerWithId(100, this.saveWithJdbcOperation);
}
private Response createCustomerWithId(int id, SaveCustomerOperation op) {
Customer c = new Customer(id, "Test " + id);
try {
op.save(c);
return Response.ok("test created id=" + c.getId()).status(Response.Status.OK).build();
} catch(Exception exp) {
StringWriter errors = new StringWriter();
exp.printStackTrace(new PrintWriter(errors));
return Response.ok("Failed: " + errors).status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
Both the JDBC and JPA implementations reside in a stateless session bean which means (I hope) that the transactions are managed by JTA:
@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class CustomerFacade {
When the testJpaFail() method is invoked, the resource fails and no response is generated: the stack trace is taken from the server logs jpa_stack_trace.txt .
|