Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the detail hibernate log
 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Those are the largest trousers in the world! Especially when next to this ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic