-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problems when trying to save a set (same identifiers)
PostPosted: Wed Aug 04, 2010 7:55 am 
Newbie

Joined: Wed Aug 04, 2010 5:39 am
Posts: 3
Hello,

I am quite new to hibernate and i would be glad if you could help. A part of the domain are entities action and action_parameter (1:m). The problem arise when i try to save an action that has many parameters with actionDao.save(Entity). Parameters are set with actionDao.setParrameters(ParameterSet set).

Result is an exception:
"a different object with the same identifier value was already associated with the session:com....*** nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session"

What can be an option? should i first try to save the action and after that parameters or can I save them together? I can see that if the ParameterSet has just one object the problem disappears so probably there is a problem with the increment of ids in the parameters entity. How does hibernate know which id is appropriate for a new insert?

Can you suggest me some tutorial how does hibernate execute inserts of objects when the result is written in multiple entities?


Top
 Profile  
 
 Post subject: Re: Problems when trying to save a set (same identifiers)
PostPosted: Wed Aug 04, 2010 8:20 am 
Newbie

Joined: Wed Aug 04, 2010 5:39 am
Posts: 3
Problem was resolved with GenericGenerator on the entity parameters.

@GenericGenerator(name = "id", strategy = "increment")
@GeneratedValue(generator = "id")

thank you,

tamau


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.