-->
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.  [ 7 posts ] 
Author Message
 Post subject: sequence oracle
PostPosted: Wed Aug 03, 2005 9:25 am 
Newbie

Joined: Mon Aug 01, 2005 3:07 am
Posts: 10
hello,

I want Id column of table increase 1, on every insertion.
I tried to use .

<id name="id" column="id" type ="long">
<generator class="sequence">
<param name="sequence">my_seq</param>
</generator>
</id>

but it did not work.

--Do I have to use trigger for this?
--Are there any built in generetor in hibernate to increase the id colunm without using oracle sequence or trigger?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 10:13 am 
Newbie

Joined: Sat Sep 13, 2003 12:45 am
Posts: 12
Location: Rochester, NY
Your XML looks correct. I would look at the logged SQL and see if the sequence object is being referenced and go from there.

_________________
Jim


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 11:22 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
What does "but it did not work" mean?
Error message? Log file? SQL output?

By the way, of course you do not need to use a sequence or a trigger.
See http://www.hibernate.org/hib_docs/v3/re ... aration-id and below.

Best regards
Sven


Top
 Profile  
 
 Post subject: sequence in oracle
PostPosted: Wed Aug 03, 2005 12:10 pm 
Beginner
Beginner

Joined: Tue Jul 19, 2005 4:03 am
Posts: 34
Location: Aberdeen, UK
Hi,

Just solved a similar issue on our team and we only had to execute a single statement on the oracle database, and then the native generator worked.

Map using native generator (not sequence)
Code:
<id name="historyID" type="java.lang.Integer" column="history_id">
    <generator class="native"/>
</id>


Error message we had:
Code:
14:18:43,951 ERROR [JDBCExceptionReporter] ORA-02289: sequence does not exist



Oracle statement that solved the problem
Code:
create sequence hibernate_sequence;


Hope this helps


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 12:16 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Well, of course you have to create a sequence.

Sequences are database objects like tables, views etc.

Code:
CREATE SEQUENCE sequencename
[INCREMENT BY value]
[START WITH value]
[{MAXVALUE value | NOMAXVALUE}]
[{MINVALUE value | NOMINVALUE}]
[{CYCLE | NOCYCLE}]
[{CACHE value | NOCACHE}];


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 12:48 pm 
Newbie

Joined: Mon Aug 01, 2005 3:07 am
Posts: 10
Thanks for all replies..

There was some problem with the sequence in oracle..
I fixed it.

On the other hand, I liked the non-sequence ways, such as "increment".


Top
 Profile  
 
 Post subject: Thank you
PostPosted: Thu May 04, 2006 1:01 pm 
Newbie

Joined: Thu Jun 23, 2005 12:25 pm
Posts: 7
Thank you for this post. There is no documentation on using the actual name "hibernate_sequence" for oracle. This fixed my problem after searching the forums for two days. Thank you again for your help.


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