-->
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: sequence id with PosGreSQL
PostPosted: Thu Jan 05, 2006 12:36 pm 
Newbie

Joined: Wed Dec 28, 2005 4:54 pm
Posts: 10
Hi and happy new year for everybody:
I have a table with an Id of type serial. when I make the ORM mapping I use the sequence mapping type. but when I tried to inset new data I receive a message saying

An unhandled exception of type 'NHibernate.ADOException' occurred in nhibernate.dll

Additional information: Could not save object


This is the code I'm using

Imagenes nueva = new Imagenes();
// Asigning the field data
session.Save(nueva);

Imagenes is a trascient class.

i read somewhere that when you use an Id of type sequence you'll need to use two insertions.
Anyway I need help with this.
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 05, 2006 1:52 pm 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
Your Id field should be mapped like:

Code:
<id name="Id" column="customerid" type="Int32">
   <generator class="native">
      <param name="sequence">customer_customerid_seq</param>
   </generator>
</id>


The important part is that the name of the sequence is specified because NHibernate does a select nextval('SEQUENCE_NAME') to retrieve the value of the Id before inserting.

_________________
Cuyahoga


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.