-->
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: Sequence id column does not support BigDecimals?
PostPosted: Mon Mar 08, 2004 6:28 pm 
Newbie

Joined: Mon Jan 19, 2004 7:44 pm
Posts: 7
Hey, I am using Hibernate2.1 and I want to use BigDecimals for all my primary keys. When I tried to have a id column that was a BigDecimal type I got this:
net.sf.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short
at net.sf.hibernate.id.IdentifierGeneratorFactory.get(IdentifierGeneratorFactory.java:38)
at net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:73)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:725)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:715)
at com.hartehanks.baton.data.HibernateBase.save(HibernateBase.java:54)
at com.hartehanks.baton.data.facade.Test.testInsert(Test.java:44)
at com.hartehanks.baton.data.facade.Test.main(Test.java:23)

Does anyone know why the sequence field does not support BigDecimals and how much effort it would be to make the IdentifierGeneratorFactory support BigDecimals?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 5:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
It should not be too difficult to create your own IdentityGenerator.


Top
 Profile  
 
 Post subject: My own IdentityGenerator
PostPosted: Tue Mar 09, 2004 11:55 am 
Newbie

Joined: Mon Jan 19, 2004 7:44 pm
Posts: 7
I modified the IdentityGeneratorFactory to return BigDecimals, but now every time I try to do an insert, it says that my object is in a transient state and Hibernate deletes it for me.


Top
 Profile  
 
 Post subject: Every answer leads to more questions
PostPosted: Tue Mar 09, 2004 12:46 pm 
Newbie

Joined: Mon Jan 19, 2004 7:44 pm
Posts: 7
I figured out why my object was being automagically deleted. It was because I was calling refresh() right after I called flush(). Why would that cause a delete?


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.