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