-->
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.  [ 8 posts ] 
Author Message
 Post subject: IdentifierGenerationException help
PostPosted: Fri Nov 14, 2003 5:13 pm 
Newbie

Joined: Thu Nov 13, 2003 4:19 pm
Posts: 4
I am using Spring with Hibernate (and struts) and I have the following issue.

When i try to save i get this:

net.sf.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():

this seems to be the line of code its failing on

getHibernateTemplate().save(to);

when i print out object to (one line ahead of it, all its values are set)
any hints?


thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 6:38 pm 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
Are you using composite-id's?
I had this problem when I had a composite-id os Long's. If that's the situation, you just need to assign the values.

Regards.


Top
 Profile  
 
 Post subject: more detail
PostPosted: Fri Nov 14, 2003 8:32 pm 
Newbie

Joined: Thu Nov 13, 2003 4:19 pm
Posts: 4
I am not using composite pks. its "assigned" (merely a string)
it seems like it should be simple. but i don't see anyone else having this issue (nor does it seem to be in the docs or FAQ), and i am not certain what i am doing wrong?

anyone?

thanks!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 8:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
If you use "assigned" id generation, you must manually initialize the identifier property. (Make sure you don't have abroken get/set pair.)

With this kind of problem it is easiest to put the Hibernate sourcecode in your sourcepath and step to the exception in your debugger.


Top
 Profile  
 
 Post subject: making progress
PostPosted: Sat Nov 15, 2003 12:37 am 
Newbie

Joined: Thu Nov 13, 2003 4:19 pm
Posts: 4
ok, i put the source in with breakpoints and did my jpda.
it still throws the exception. which (to me) means that the problem probably is with spring & the way i am getting the template setup.

i tried to put spring source into path too, but that seems to have tons of dependencies that are not in my project (j2ee, aop, etc)

any hints on that?


Top
 Profile  
 
 Post subject: manually initialize the identifier property with Spring
PostPosted: Wed Nov 19, 2003 11:51 pm 
Newbie

Joined: Sun Nov 16, 2003 11:44 am
Posts: 7
How would one "manually initialize the identifier property"
of a manually assigned id (user defiend PK) form a many to one (one way) relationship.

because i can't get rid of this message on update

ids for this class must be manually assigned before calling save()

it should be easy, what am i missing?

(oh i am using spring) (hibernateTemplate)

thanks in advance

-Fred


Top
 Profile  
 
 Post subject: another question
PostPosted: Thu Nov 20, 2003 10:39 pm 
Newbie

Joined: Sun Nov 16, 2003 11:44 am
Posts: 7
if this values would be loaded thru a many to one, why should its id need to be set? its loaded?

can someone explain this to me?

thank you very much

-F


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 3:46 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
Parent p = new Parent();
p.setId("myId"); //manually assigned
Child c = new Child();
c.setId("myChildId); //manually assigned
c.setParent(p);
...
session.save(p);
session.save(c);
session.flush();

_________________
Emmanuel


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