• Post Reply Bookmark Topic Watch Topic
  • New Topic

What am i allowed to do during jpa callbacks  RSS feed

avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In the book - "java persistence with hibernate" they write;
It�s illegal to invoke the original Hibernate Session from an Interceptor callback.
The Session is in a fragile state during interceptor calls.

I am working with JPA and want to do some things like queries or change the object or create a reference from this object to other objects in the callbacks events like post-persist and etc.

I am working with JPA and the underline implementation is hibernate, so I am assume that the same rule that quoted above is relevant also to JPA callback?
Am I right?
Can you please give examples for things that you are doing on callbacks?

In the book they suggest the following trick -
A nice trick that avoids this issue is
Opening a new Session only for the purpose of saving a single AuditLogRecord
Object. You reuse the JDBC connection from the original Session.

How can use this trick as concern to entity manager is JBoss, am I need to use the same trick?

Thank you
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!