-->
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: Sequence HiLo with Oracle and Hibernate Tools
PostPosted: Mon Feb 05, 2007 5:28 pm 
Newbie

Joined: Mon Jul 17, 2006 2:13 pm
Posts: 8
Location: Paris
Hello,

I would like to report a problem with seqhilo,
not working when reverse engineering my db schema
with Hibernate tools and the following code in reveng.xml
(Hibernate Hibernate 3.2.0.GA from JBoss AS 4.0.5.GA):

Code:
   <table name="TEST">
      <primary-key>
         <generator class="seqhilo">
            <param name="sequence">HISEQ_TEST_ID</param>
            <param name="max_lo">1000</param>
         </generator>
         <key-column name="TEST_ID" />
      </primary-key>
   </table>


I get this code in Test.java entity:

Code:
        ....
   @GenericGenerator(name = "generator", strategy = "seqhilo", parameters =
   { @Parameter(name = "max_lo", value = "1000"),
         @Parameter(name = "sequence", value = "HISEQ_TEST_ID") })
   @Id
   @GeneratedValue(generator = "generator")
        ....


This does NOT work, at least with Oracle (JDK 1.4 drivers) -- I haven't tested other dbs.

--> This gives a simple sequence as if HiLo was not defined.

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

Then I tried the following modification on Test.java:

Code:
   @GenericGenerator(name = "generator", strategy = "seqhilo", parameters =
   { @Parameter(name = "max_lo", value = "1000"),
         @Parameter(name = "sequence", value = "HISEQ_TEST_ID") })
   @Id
   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "generator")


Added: strategy=GenerationType.SEQUENCE


--> This gives a HiLo sequence with strange initialization of the "lo" part, namely if your sequence is 1000186, you will get 1000186186 as first id


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

I finally got a working SequenceHiLo with the following code:

Code:
@SequenceGenerator(name = "generator", sequenceName = "HISEQ_TEST_ID", allocationSize = 1000)
   @Id
   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "generator")



--> Gives 1000187000 as first id as expected (and 001, 002, etc. after !)


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

So my questions are:

** Is the last code the right way to do so (giving up the GenerationType.AUTO)?

** Isn't there some bug in the @GenericGenerator?

** Shouldn't the Tools generate this code in case of SequenceHiLo (and shouldn't there be a special command for that)?



Congratulations for your great work!

--Eric


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 8:16 am 
Newbie

Joined: Mon Jul 17, 2006 2:13 pm
Posts: 8
Location: Paris
Should I post a JIRA issue on this ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 5:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, post a jira with a ref to this forum post.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 10:08 am 
Newbie

Joined: Mon Jul 17, 2006 2:13 pm
Posts: 8
Location: Paris
Done. Thank you Max.


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.