-->
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.  [ 4 posts ] 
Author Message
 Post subject: native "id" not being generated..
PostPosted: Tue Mar 21, 2006 4:54 pm 
Newbie

Joined: Tue Mar 21, 2006 4:44 pm
Posts: 4
I chose the NAtive ID generation in hbm mapping file.

The session.save(NewObj) fails with "org.hibernate.exception.ConstraintViolationException: ..." saying Insertion failed due to Null ID. I didn't populate this ID in my code assuming Native system will take care of generating this ID value(of type long in my case) when we insert. Any clues?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 6:02 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
depends on the native system.

Hibernate's Oracle Dialect will try to use
hibernate_sequence.nextval to get a sequence, and if you haven't created
the sequence "hibernate_sequence" then it will fail.

Others perhaps would use the "identity" field in the database -- ie, MySQL supports auto gen keys when you do an insert, whereby you don't have to pass anything for value in the key.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 8:55 pm 
Newbie

Joined: Tue Mar 21, 2006 4:44 pm
Posts: 4
Sybase is the DB used and I guess "native" should use "identity".
I also tried "identity" as the generator class. Still the same problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 12:05 am 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
choosing native should automatically choose the correct method - between sequence or identity.

Can you post your XML mapping file and its table definition.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


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