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: Weird problem with Auto Generated Id
PostPosted: Wed Sep 01, 2010 4:34 pm 
Newbie

Joined: Tue Aug 17, 2010 3:16 pm
Posts: 8
I'm having a problem with Auto Generated Id here is what I have on my code

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public int getId() {

return id;
}

but when I create a class the id that the object have is = 0 , then when I try to find it by the id using the function of Session load(Class, int) is imposible 'cuz it cause this problem

org.hibernate.ObjectNotFoundException: No row with the given identifier exists:

but I can list all the objects that I've entered and all of them have the id = 0.

The weird part is that I have another class using
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
and the same function and it works!!!

Please if you know why this is happening help me!!!


Top
 Profile  
 
 Post subject: Re: Weird problem with Auto Generated Id
PostPosted: Fri Sep 03, 2010 4:19 pm 
Newbie

Joined: Tue Aug 17, 2010 3:16 pm
Posts: 8
I was getting the Id before I've saved the object.... I fix it just saving the Object before getting the id XD hehehehe


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.