-->
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.  [ 3 posts ] 
Author Message
 Post subject: Id generator for trigger
PostPosted: Sat Aug 26, 2006 10:38 am 
Beginner
Beginner

Joined: Wed Aug 31, 2005 3:54 am
Posts: 45
Hi !
We use trigger to automaticaly create primary key for all news records in Oracle 10.
What generator do we use in Hibernate to declare id ?

<id name="myId" column="MY_ID">
<generator class="???">
</generator>
</id>


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 27, 2006 3:41 pm 
Beginner
Beginner

Joined: Tue Apr 05, 2005 12:09 pm
Posts: 48
Location: Slovakia (SK), Košice (KE)
Hi

I think it is "org.hibernate.id.SelectGenerator"; see this: http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-id-generator

_________________
Martin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 22, 2006 6:58 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
I'm trying to solve the same problem, although I'm using oracle 9i. I tried the "select" generator, but it's not quite working. From my HBM file:

<id name="oid">
<column name="OID"/>
<generator class="select">
<param name="key">OID</param>
</generator>
</id>

When I run with this, I get the exception that follows this. My Java "oid" property is an "int", and my column is defined as NUMBER(10). I tried stepping into the Hibernate code for this. It's a little hard to interpret, but it seems like the resultset has a single column, named "ROWID", but I could be misinterpreting what I'm seeing in the debugger.

Caused by: java.sql.SQLException: [BEA][Oracle JDBC Driver]Value can not be converted to requested type.
at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
at weblogic.jdbc.base.BaseData.getInteger(Unknown Source)
at weblogic.jdbc.base.BaseResultSet.getInt(Unknown Source)
at weblogic.jdbc.wrapper.ResultSet_weblogic_jdbc_base_BaseResultSet.getInt(Unknown Source)
at org.hibernate.id.IdentifierGeneratorFactory.get(IdentifierGeneratorFactory.java:50)
at org.hibernate.id.IdentifierGeneratorFactory.getGeneratedIdentity(IdentifierGeneratorFactory.java:35)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1761)


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