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: Associated entities not updated in transaction
PostPosted: Fri May 15, 2009 7:33 am 
Newbie

Joined: Fri May 15, 2009 6:16 am
Posts: 1
Hello

I have two entities, Kurs and ParameterRef with a @OneToMany relation:

@Entity
@Table(name="KURS")
public class Kurs {

@Id
@Column(name = "KURS_ID", nullable = false)
private Integer kursId;

...

@OneToMany(fetch=FetchType.LAZY, mappedBy = "kurs")
private List<ParameterRef> parameterRefs = new ArrayList<ParameterRef>();
}

In a transaction I create and persist a Kurs object and then uses myNewKurs.getKursId() to create and persist a ParameterRef object. When this is done I use entityManager.find(Kurs.class, myNewKurs.getKursId()) to retreive a new updated Kurs instance with the parameterRefs-list updated and associated with my new created ParameterRef, but this fails when I am doing it in the same transaction used to create the new Kurs and ParameterRef objects and I only get a empty parameterRefs list.

If I let the transaction end and commit the changes and then use entityManager.find() in the same way i retrieve my Kurs object and a populated parameterRefs list containing my created ParameterRef. Is this the proper behaviour for hibernate? Can I have my new created Kurs-objekt updated within the transaction used to persist the enitity?

Regards
Johan


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.