-->
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: Solution for the hard to understand problem of id changing
PostPosted: Tue Apr 04, 2006 7:02 am 
Newbie

Joined: Tue Apr 04, 2006 6:58 am
Posts: 4
Location: Tampere,Finland
Caused by: org.hibernate.HibernateException: identifier of an instance of <class> altered from <x> to <y>

This is caused, spare from you actually doing the ID change, from using f.ex. 'int' instead of 'Integer' as object id.

So, if your code looks like this:

public class HibernateObject {
private int id;

public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}
}

You will have to change it to:

public class HibernateObject {
private Integer id;

public Integer getId() {
return this.id;
}

public void setId(Integer id) {
this.id = id;
}
}

And it works. In my humble opinion this is very silly behaviour, but I guess there is a reason why it works like this.

Hope this helps someone.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 06, 2006 3:24 am 
Newbie

Joined: Thu Jun 01, 2006 5:09 am
Posts: 16
I'm using a String type to identify the ID. How can I do?


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.