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.  [ 4 posts ] 
Author Message
 Post subject: database-provided identity in Oracle
PostPosted: Thu Mar 29, 2007 9:09 am 
Newbie

Joined: Thu Mar 29, 2007 6:15 am
Posts: 1
For an Oracle identity column generated by the database (eg., via insert trigger) the built-in generator="identity" is not supported by Hibernate (as of version 3.2.2). Instead of this, generator="sequence-identity" is supported on Oracle 10g (see http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-id-generator).

In reverse-engineered databases, a dummy sequence "HIBERNATE_SEQUENCE" must be created manually, because Hibernate references this sequence in the insert statement.

Annotation Syntax Example:
Code:
  import org.hibernate.annotations.GenericGenerator;
 
  @Id
  @GeneratedValue( generator="hibsid" )
  @GenericGenerator( name="hibsid", strategy="sequence-identity" )


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

Joined: Thu Dec 23, 2004 5:24 am
Posts: 40
Location: Luxembourg
See also this:

http://forum.hibernate.org/viewtopic.php?t=973262


Top
 Profile  
 
 Post subject: Problem with sequence-identity
PostPosted: Fri Oct 05, 2007 9:05 am 
Newbie

Joined: Mon Oct 17, 2005 11:56 am
Posts: 16
Location: Arlington, VA
I was able to use sequence-identity in JBoss 4.0.5SP1, but not JBoss 4.2.0. Does anyone know what needs to be changed when moving up? These versions of JBoss use different versions of Hibernate, so it might be related to that. I'm using JDK 1.5.0_11 and Oracle 10g.

I'm using

org.hibernate.dialect.Oracle9Dialect

in both hibernate.cfg.xml and hibernate-service.xml.

AFIK, Hibernate provides no Oracle10Dialect, even though this is a feature that ONLY works with Oracle 10g!



The exception I get in JBoss 4.2.0 is:


Caused by: java.sql.SQLException: Unsupported feature
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.dbaccess.DBError.throwUnsupportedFeatureSqlException(DBError.java:690)
at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:3492)
at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:256)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.util.NamedGeneratedKeysHelper.prepareStatement(NamedGeneratedKeysHelper.java:42)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:498)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
at org.hibernate.id.SequenceIdentityGenerator$Delegate.prepare(SequenceIdentityGenerator.java:76)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:30)
... 80 more


Thanks


Top
 Profile  
 
 Post subject: Re: Problem with sequence-identity
PostPosted: Fri Oct 05, 2007 10:14 am 
Beginner
Beginner

Joined: Thu Dec 23, 2004 5:24 am
Posts: 40
Location: Luxembourg
fisherv wrote:
I was able to use sequence-identity in JBoss 4.0.5SP1, but not JBoss 4.2.0.


Are you using the same version of the JDBC driver ? This id generator uses a JDBC3 feature that is only available in the latest versions of the driver. If you are using a 9i driver, it won't work. It will however work with a 9i database accessed from a 10g driver.

fisherv wrote:
org.hibernate.dialect.Oracle9Dialect


That's fine: Oracle9Dialect works with Oracle version 9 and upper (including Oracle 10g).


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