Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: hibernate_sequence.nextval
PostPosted: Mon Apr 19, 2004 11:36 am 
Beginner
Beginner

Joined: Mon Sep 29, 2003 2:18 pm
Posts: 20
Trying to get a sequence, I get output:

select hibernate_sequence.nextval from dual

I'm using the syntax that is found in the documentation, but it doesn't seem to be picking up my sequence name.

Thanks,
Steve

--------------------------------------------------

Version: 2.1.2
Mapping Doc:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="Modality">

<class name="com.cti.resource.Modality" table="PRTL_MODALITY">
<id name="id" column="id" type="long">
<generator class="sequence">
<param name="sequence">PRTL_MODALITY_ID_SEQ</param>
</generator>
</id>
<property name="name" />
<property name="description" />
<property name="providerId" column="provider_id"/>
<property name="deletedBy" column="deleted_by"/>
<property name="deletedDate" column="deleted_date"/>
<property name="modifiedBy" column="modified_by"/>
<property name="modifiedDate" column="modified_date"/>
<property name="deleted"/>
</class>

</hibernate-mapping>

Code:


Modality mod = new Modality();

Session hibsession = null;
try {
hibsession = HibernateUtil.currentSession();
}
catch (net.sf.hibernate.LazyInitializationException lie) {
lie.printStackTrace();
}
mod.setDescription("desc");
mod.setName("name");
if (hibsession != null) {
hibsession.save(mod);
HibernateUtil.closeSession();
}

Stack Trace:

10:27:37,787 ERROR [JDBCExceptionReporter] Could not save object
java.sql.SQLException: ORA-02289: sequence does not exist

DB Version: Oracle 8i


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 2:40 pm 
Beginner
Beginner

Joined: Sat Nov 22, 2003 3:54 pm
Posts: 42
The ORA error points out that it can't find the sequence in the DB.
Your sequence name in the mapping is "PRTL_MODALITY_ID_SEQ", try to do the nextval on this sequence name first . Also you need to make sure that which schema you are referring to. Also to select from a sequence without specifying the object owner, it has to exist in your current schema or you just need to create a synonym which points to the sequence in
another schema.


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Mon Apr 19, 2004 2:56 pm 
Beginner
Beginner

Joined: Mon Sep 29, 2003 2:18 pm
Posts: 20
Okay, I think I got it. Somehow it was getting the wrong version of my .xml or something, everything works fine now that I restarted JBoss.

Steve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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.