-->
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.  [ 8 posts ] 
Author Message
 Post subject: Oracle sequence error
PostPosted: Mon Dec 08, 2003 2:35 pm 
Newbie

Joined: Mon Dec 08, 2003 2:21 pm
Posts: 10
Hibernate does not generate the primary key based on the Oracle sequence specified in the mapping file. The sql shows Hibernate is reading the nextval of the sequence, but the database primary column is not the same value. Is it a bug?

Here is some detailed information:

1) I use hibernate-2.1rc1.zip

2) my mapping:

<id
name="userCompanyId"
type="long"
column="USER_COMPANY_ID"
unsaved-value="0"
>
<generator class="sequence">
<param name="sequence">SQ_USER_COMPANY</param>
</generator>
</id>

3) sql shows:

Hibernate: select SQ_USER_COMPANY.nextval from dual
userCompanyId = 9
Hibernate: insert into USER_COMPANY (DESCRIPTION, IS_PROVIDER, ABBREVIATION, ROW_VERSION, UPDATED_BY, UPDATED_DT, USER_COMPANY_ID) values (?, ?, ?, ?, ?, ?, ?)

4) database value is: 3.7E-51 for USER_COMPANY_ID (NUMBER(15), not 9

What is going on there? any help will be greatly appreciated?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 08, 2003 3:10 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
There was similar problem recently: http://forum.hibernate.org/viewtopic.php?t=925469

(At leasy I think it is similar:)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 10:08 am 
Newbie

Joined: Fri Feb 20, 2004 10:55 am
Posts: 13
I saw many peoples with the same problem, I'm having this problem, but it stills without solution.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 10:57 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
I use Oracle 9i and my sequences work well.
Try to use the lasest JDBC driver from Oracle.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 10:59 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
I use Oracle 9i and my sequences work well.
Try to use the lasest JDBC driver from Oracle.
I use Integer for my keys and not long maybe there is a bug with primitive type.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 12:32 pm 
Newbie

Joined: Fri Feb 20, 2004 10:55 am
Posts: 13
I use Oracle 8i, java.lang.Long in the primary keys and ojdbc14.jar. All right?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 4:45 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Hi all,

I need help because I have a problem with an oracle sequence. I answered to this post to help "jhcadr" but today I have this strange problem and I don't understand why.

So I try to explain my problem. I use Hibernate 2.1.4, BEA 8.1 SP2 and Oracle 8.
I try different version of Oracle drivers but it's always the same result.
When the select XX_SQ.nextval from dual, I have the right number in log but when the insert is done I have a result like this 1,45112E.

I don't know why if it's a driver probem, an hibernat problem with Oracle dialect.

I worked on different project with Hibernate but it's the first time I have this. Last month I use the same Oracle server but on another schema and it's work well. The only difference today is that I have an Integer on the TABLE definition and usually it's an Oracle NUMBER.

If someone have an idea please help :+)

Kind regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 6:08 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
I think I have found the solution for this problem.
With Oracle it seems we must use a NUMBER in database schema and increment it with a sequence (not Integer, long or other exotic type).


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