-->
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: Hibernate using hilo instead of seqhilo strategy
PostPosted: Tue Apr 24, 2007 2:05 am 
Newbie

Joined: Sun Apr 22, 2007 10:33 pm
Posts: 11
Hi *,
We are using Hibernate version 3.2.0.ga with Hibernate Annotations 3.2.1.ga with
The database I'm using is Oracle9i.

All the tables in the database have ID of long type. We also have corresponding HIbernate Domain objects that are based on the database schema.

Now, we are trying to use Oracle Sequences to retieve and assign the sequence Ids to the tables (primary key).

For some reason, eventhough hibernate is retieving Oracle Sequence Id (database native), it is using Hibernate generated sequence id. We badly want to use the Oracle (native) sequence Id rather than HIbernate Generated Sequence Ids.

As you can see this is happening despite using "strategy = GenerationType.SEQUENCE" in annotations.

The annotations we are using are as follows

= = = = = = = = = = = = DB TABLE NAME is EMPLOYEE = = = = = = = = = = = = = = = = =
:
@Entity
@Table(name = "EMPLOYEE")
@javax.persistence.SequenceGenerator(name = "EMPLOYEE_STORE", sequenceName = "EMPLOYEE_SEQ")


:
:

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EMPLOYEE_STORE")
public Long getId() {
return this.id;
}
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Any clues on why hibernate is using wrong "Identifier generation strategy" (use hilo strategy instead of seqhilo strategy).

Any help is much appreciate.

_________________
~/Gurram


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 24, 2007 5:46 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi,

In the SequenceGenerator annotation, try adding the following:

Code:
allocationSize = 1, initialValue= 1

In my opinion the allocationSize is the important one.

Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 3:09 am 
Newbie

Joined: Sun Apr 22, 2007 10:33 pm
Posts: 11
Thanks Andy. That worked like a charm.

However, I'm unsure if this is a bug or 'use-it-the-right-way' thing :-). Any case, it solved my problem. Are there any pointers that are worth reading on this area?

I came across this, that looks similar to my problem...
http://jira.jboss.com/jira/browse/EJBTHREE-597

Theit solution is to use "org.hibernate.annotations" rather than "javax.persistence."
That is use:
-------------------------------- WORK-AROUND??? --------------------------------
@org.hibernate.annotations.GenericGenerator(name="Question_id_sequence", strategy = "sequence",
parameters = { @Parameter(name="sequence", value="S_QUESTION") } )
-------------------------------- FOR --------------------------------
@javax.persistence.SequenceGenerator(name = "Question_id_sequence", sequenceName = "S_QUESTION")

_________________
~/Gurram


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 3:18 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is how it is supposed to work, I agree allocationSize should have a better default...

_________________
Emmanuel


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.