-->
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: How to get a sequence value from a generator using Firebird
PostPosted: Sat Nov 15, 2003 12:50 am 
Newbie

Joined: Sat Nov 15, 2003 12:32 am
Posts: 1
I am trying to obtain the nexval in a sequence from a generator in Firebird.
Configuration cfg = new Configuration().addClass( com.nash.value.Contact.class );
SessionFactory sessions = cfg.buildSessionFactory();
Session sess = sessions.openSession(); // obtain a JDBC connection and
Transaction trans = sess.beginTransaction();

Contact contact = new Contact();
contact.setFirstName( "foo" );
contact.setLastName( "bar" );
sess.save( contact );
trans.commit();

The debug shows that the next value is obtained, however, an exception is thrown:
net.sf.hibernate.HibernateException: identifier of an instance of com.nash.value.Contact altered from 10604 to 10604 ...

The documentation says that using a sequence requires two SQL queries to insert a new object. Can someone give me an example of how to insert a new record in a table using a sequence?

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 15, 2003 1:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You have mapped the identifier with an incorrect type. So what is happening is Hibernate class Integer.equals(Long), or something.


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.