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.  [ 1 post ] 
Author Message
 Post subject: Refresh after 1-to-m related item is deleted from db
PostPosted: Fri Jun 27, 2008 5:57 pm 
Newbie

Joined: Fri Jun 27, 2008 5:18 pm
Posts: 1
Hibernate version: Hibernate 3.2.6, annotations 3.3.1 and entitymanager 3.3.2

L2 Caching disabled

Name and version of the database you are using: Postgres 8.2

I have two entities:
Parent and child, with parent.children as a OneToMany relationship to child.

A parent and all its children are read by one EntityManager and transaction (EM1). FWIW, no changes are made to the parent or children.

While that transaction is still open, another process removes one of the children.

I cannot find how to refresh the parent into the first EntityManager EM1:
em1.find(Parent.class, parent.getId()) just returns the cached copy (complete with

em1.refresh(parent) throws an EntityNotFoundException, referring to the deleted child [Also known as a UnresolvableObjectException]

((HibernateEntityManager)em1).getSession().evict(parent) throws
org.hibernate.PersistentObjectException: detached entity passed to persist [probably because I don't have any hibernate-specific/evict cascades]


So, my questions are:
Should just plain old em.refresh( parent ) refetch a new list of children? If so, I'll be happy to post many more details about my entities, logs, etc to figure out why it is not working for me.

If em.refresh() is not expected to work, is there a way to get an updated parent into its existing EntityManager?

Do I need to create a new EM and just read the parent from scratch?


Thanks much,
Bert


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

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.