-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How to remove native deleted entities from a EntityManager
PostPosted: Wed Aug 12, 2009 9:52 am 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
Hi,
In my application I have several EntityManager at the same time. In some cases I delete entities via a native query (to increase the performance) - NOT via EntityManager.remove(..). My question is: How to remove these (already deleted) entities from all/one EntityManager?
Re-initialization oft he existing EntityManager is not a accepted solution.

Note: I have a List with all removed entities - So I have all necessary information about the deleted entities.

Thanks
QStorm

_________________
http://nocxsville.myminicity.com/


Top
 Profile  
 
 Post subject: Re: How to remove native deleted entities from a EntityManager
PostPosted: Sat Aug 15, 2009 5:11 am 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
Has nobody a solution?

_________________
http://nocxsville.myminicity.com/


Top
 Profile  
 
 Post subject: Re: How to remove native deleted entities from a EntityManager
PostPosted: Tue Sep 01, 2009 10:54 am 
Regular
Regular

Joined: Fri May 12, 2006 4:05 am
Posts: 106
Seems like there is no JPA-1.0-compliant way to do this.

The only way I can think of is to access the hibernate -Session (which is the EntityManager's delegate) and use session.evict(anObject)...


Top
 Profile  
 
 Post subject: Re: How to remove native deleted entities from a EntityManager
PostPosted: Wed Sep 09, 2009 11:12 am 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
Hi,
Thanks for the answer. It seems to work. Here the code for someone with the same issue:

Code:
final List<Entity> entities = new ArrayList<Entity>();
// ...
final SessionImpl session = (SessionImpl) manager.getDelegate();
for(E current : entities) session.evict(current);


Best regards
QStorm

_________________
http://nocxsville.myminicity.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.