-->
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.  [ 6 posts ] 
Author Message
 Post subject: generator class='?" if using trigger to do id generatio
PostPosted: Thu Oct 26, 2006 3:16 pm 
Beginner
Beginner

Joined: Thu Oct 05, 2006 4:00 pm
Posts: 22
Hi,

here is my xml file

<!-- id property. -->
<id name="id"
type="integer"
column="ATTR_ID"
unsaved-value="null"
access="field">
<generator class="assigned"/>
</id>

here is the trigger

CREATE OR REPLACE TRIGGER TRG_VALUE
BEFORE INSERT ON value
FOR EACH ROW
BEGIN
SELECT VALUE_SEQ.NEXTVAL,user,sysdate,user,sysdate
INTO :new.attr_val_id,:new.cuser,:new.cdate,:new.muser,:new.mdate
FROM dual;
END;

When I try to insert, I got an error like

ORA-02289 sequence does not exist
select hibernate_sequence.nextval from dual

Any clue? Thanks much.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 26, 2006 4:15 pm 
Beginner
Beginner

Joined: Thu Oct 05, 2006 4:00 pm
Posts: 22
anyone here?


Top
 Profile  
 
 Post subject: Permissions?
PostPosted: Thu Oct 26, 2006 4:43 pm 
Newbie

Joined: Thu Oct 12, 2006 6:12 pm
Posts: 8
Well, to address your posted question, I'd investigate permissions on your sequence.

However, the solution you have proposed will require that hibernate query the DB after an insert in order to get the recently assigned ID. I'm not 100% on how to do that.

What I suggest you do instead is change the generator to a sequence, like this:
Code:
<id name="id"
type="integer"
column="ATTR_ID"
unsaved-value="null"
access="field">
<generator class="sequence"><param name="sequence">VALUE_SEQ</param></generator>
</id>

You can also add in a <timestamp> for your other columns.

Good luck!
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 26, 2006 4:56 pm 
Beginner
Beginner

Joined: Thu Oct 05, 2006 4:00 pm
Posts: 22
I tried this approach,

when I call save() in the code. After save(), I print out the object and it uses value 10000.

however, when i look into the db, the actual value it's used is 10001.

any help from hibernate team?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 1:29 pm 
Beginner
Beginner

Joined: Thu Oct 05, 2006 4:00 pm
Posts: 22
any help?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 8:21 am 
Beginner
Beginner

Joined: Thu Dec 23, 2004 5:24 am
Posts: 40
Location: Luxembourg
Have a look here: http://forum.hibernate.org/viewtopic.php?t=973262


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