Forcing a method to be non-transactional in JPA (Eclipselink)

Posted by rhinds on Stack Overflow See other posts from Stack Overflow or by rhinds
Published on 2010-05-10T18:08:51Z Indexed on 2010/05/11 5:44 UTC
Read the original article Hit count: 213

Filed under:
|
|

Hi,

I am developing an application using Eclipselink and as part of the app I need to be able to manipulate some of the objects which involves changing data without it being persisted to the database (i merging/changing objects for some batch generation processes).

I am reluctant to change the data in the Entity objects, as there is a risk that even though i have not marked the methods as @Transactional, this method could in the future be inadvertantly called from within a transactional method and these changes could be persisted.

So my question is, is there anyway to get around this? Such as force a method to always be non-transactional regardless; terminate any transactionality as soon as the method is started; etc.

I know there is a .detach() method that can detach the objects from the Entity Manager, however, there are many objects and this seems like a potentially error prone fail-safe on my code.

© Stack Overflow or respective owner

Related posts about jpa

Related posts about eclipselink