This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate insert or select gives Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate insert or select gives "Identifier of an instance altered"" Watch "Hibernate insert or select gives "Identifier of an instance altered"" New topic
Author

Hibernate insert or select gives "Identifier of an instance altered"

Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
I'm new to Hibernate and just trying to get the quickstart up and running that is in the first chapter of the hibernate tutorial. I'm using Hibernate 3.0.5. When running the following code in my servlet:



I get the following error:

org.hibernate.HibernateException: identifier of an instance of org.hibernate.examples.quickstart.Cat altered from 1 to null

Here is the hibernate.cfg.xml and cat.hbm.xml:



I am using MySQL database 4.1.12a with the MySql connector 3.1.10 on Windows XP. My script to create the table in Mysql is:

create table cat (
cat_id varchar(32) not null,
name varchar(16) not null,
sex char(1) not null,
weight float(2),
primary key (cat_id)
);

What is causing this error? Any help is greatly appreciated!
Thanks
Brian
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

Can you post the detail hibernate log


[My Blog] [JavaRanch Journal]
Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
The problem was in my persistent class, I had typed the set field incorrectly. Doh!

private Long id;
public void setId(Long Id) {
this.id = id;
}

Thanks
Brian
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate insert or select gives "Identifier of an instance altered"
 
Similar Threads
Foreign Key Constraint Fails
hibernate problem
Hibernate not finding Oracle driver - despite straight JDBC working
Hibernate3.0 with DB2 8.1.3UDB - org.hibernate.exception. SQLGrammarException
Hibernate does not save Object / Record