-->
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: problem of generating a primary key
PostPosted: Thu Dec 22, 2005 11:21 pm 
Newbie

Joined: Thu Dec 22, 2005 11:15 pm
Posts: 13
Hi,

I use JDK1.4.1 + hibernate-3.1 + oracle9.

The section of mapping file for generating a primary key is as following:

Code:
<generator class="seqhilo">
   <param name="sequence">HIBERNATE_UNIQUE_KEY</param>
   <param name="max_lo">100</param>
</generator>


I have already create a table named "HIBERNATE_UNIQUE_KEY" with a field named "nextval". DataType of nextval is number(38).

When I save the object, the exception says as following:

Code:
Hibernate:
    select
        GDW2.HIBERNATE_UNIQUE_KEY.nextval
    from
        dual
20:07:17,307  WARN JDBCExceptionReporter:71 - SQL Error: 2289, SQLState: 42000
20:07:17,307 ERROR JDBCExceptionReporter:72 - ORA-02289: serial(number) does not exist
org.hibernate.exception.SQLGrammarException: could not get next sequence value
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)


Could anyone tell me how to set the parameters and environment for
<generator class="seqhilo">?

And, is it imperative that I should create several tables for several entities which need a generated key? Is there anyway to share the sequence table with different fields?

Also, in my environment, what is the most efficient algorithm?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 5:12 am 
Beginner
Beginner

Joined: Thu Sep 01, 2005 7:43 am
Posts: 31
Location: León (Spain)
I'm using PostgreSQL but i really doubt you can do that with a table. Sequence numbers in postgre are created as follows:

CREATE SEQUENCE hibernate_sequence
INCREMENT 1
MINVALUE 1000
MAXVALUE 9223372036854775807
START 1000
CACHE 1;

Try searching for sequence syntax in oracle.

Hope this helps.
Bye.

_________________
Please rate...

Expert on Hibernate errors... I've had them all... :P


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 6:38 am 
Beginner
Beginner

Joined: Tue Sep 20, 2005 4:32 am
Posts: 29
Location: Cluj-Napoca
What I'm using to generate a primary key on Oracle is:

<generator class="native">
<param name="sequence">SEQUENCE_NAME</param>
</generator>

and I create the sequence into Oracle db schema using CREATE SEQUENCE... command.

That's all.

Cristian.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 25, 2005 9:51 pm 
Beginner
Beginner

Joined: Tue Nov 01, 2005 5:21 am
Posts: 24
You might also use seqhilo, while the sequence_name is the name of sequence.


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.