-->
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.  [ 5 posts ] 
Author Message
 Post subject: i searched the FAQ and chapter 4, basic O/R mapping and...
PostPosted: Tue Sep 16, 2003 9:01 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
have a problem with using the generator:
Code:
       <generator class="seqhilo">
                <param name="sequence">hi_value</param>
                <param name="max_lo">100</param>
        </generator>

in my mapping file. I am connecting to an Oracle 9i database through a JNDI-based OC4J container-managed JDBC connection pool. The error i get in my log file is
Quote:
prepared statement get: select hi_value.nextval from dual
DEBUG [RMICallHandler-5] (SessionFactoryImpl.java:557) - preparing statement
DEBUG [RMICallHandler-5] (JDBCExceptionReporter.java:34) - SQL Exception
java.sql.SQLException: ORA-02289: sequence does not exist

The error makes some sense as i do not have these attributes in the database, which leads to my question. How do you configure, and what do you need to configure, to get an auto-generated ID for a newly created object when you are saving the newly created object?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 9:18 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
i did some digging and figured it out. thanks anyways :-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 9:27 pm 
Beginner
Beginner

Joined: Fri Sep 12, 2003 12:54 pm
Posts: 20
You simply need to create the correct sequence(s) in Oracle for generating your Ids.

If you tell the Hibernate configuration that the sequence is called "hi_value" (as in the example) then you need to create a sequence in Oracle with that name:

Code:
CREATE SEQUENCE hi_value;


or something like:

Code:
CREATE SEQUENCE hi_value START WITH 100 INCREMENT BY 1


etc. (I'm doing this by memory - so check your Oracle docs for syntax).

that's really all there is to it, other than providing Hibernate the configuration as in your example.

james


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2003 5:56 am 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
thanks, this was exactly the issue. i had to make a sequence and i used the standard oracle syntax:

Code:
CREATE SEQUENCE <my_sequence_name>;


After adding the sequence the insert worked fine.


Top
 Profile  
 
 Post subject: Sequence
PostPosted: Wed Sep 17, 2003 11:29 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 6:44 pm
Posts: 20
Use hbxmltoddl tool to generate the ddl statement.


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