-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to modify a primary key...
PostPosted: Mon Sep 25, 2006 7:11 am 
Newbie

Joined: Mon Sep 25, 2006 7:04 am
Posts: 7
Hi,

I have a "HibernateException: identifier of an instance of com.webdmt.modelo.hibernate.Departamento was altered from Departamento de Informática to Laboratorio DEI" when trying to modify a primary key.

How can i modify a primary key without having this Exception?

Thanx guys!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 7:15 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It's the very definition of a primary key that the value of this attribute never changes as long as the record is alive.

http://en.wikipedia.org/wiki/Primary_key


Top
 Profile  
 
 Post subject: but...
PostPosted: Mon Sep 25, 2006 7:22 am 
Newbie

Joined: Mon Sep 25, 2006 7:04 am
Posts: 7
Hi again,

Well i know but... if your database definition has Update: cascade you could modify even primary keys.

When i use directly in MySQL-command line, a sentence like : update departamento set nombre_departamento = "new id" where nombre_departamente = "old id"
mysql lets me change it, and changes all tables where nombre_departamento is a foreign key.

Can't Hibernate do the same?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 7:48 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, and it's a very very bad idea.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 25, 2006 8:06 am 
Newbie

Joined: Mon Sep 25, 2006 7:42 am
Posts: 7
We never change primary key or use update query to change the primary key, it is never recommened.

_________________
Never Give Up


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