当前位置:网站首页>Detach an entity from jpa/ejb3 persistence context

Detach an entity from jpa/ejb3 persistence context

2022-06-26 07:36:00 French red wine sweet

problem :

What would be the easiest way to detach a specific JPA Entity Bean that was acquired through an EntityManager. Separation pass EntityManager Get specific JPA Entity Bean What's the easiest way to do it .Alternatively, could I have a query return detached objects in the first place so they would essentially act as 'read only'? perhaps , Can I first have the query return a separate object , So that they basically act as “ read-only ”?

The reason why I want to do this is becuase I want to modify the data within the bean - with in my application only, but not ever have it persisted to the database. The reason I want to do this is because I want to modify bean Data in - Use only in my application , But it is never persisted to the database .In my program, I eventually have to call flush() on the EntityManager, which would persist all changes from attached entities to the underyling database, but I want to exclude specific objects. In my program , I finally have to EntityManager On the call flush(), This saves all changes from the attached entity to the underlying database , But I want to exclude certain objects .


Solution :

Reference resources : https://stackoom.com/en/question/8BC
原网站

版权声明
本文为[French red wine sweet]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202171038412674.html