Hi/lo algorithm in Hibernate

By: Dorris Viewed: 153298 times  Printer Friendly Format    


The hilo and seqhilo generators provide two alternate implementations of the hi/lo algorithm. The first implementation requires a "special" database table to hold the next available "hi" value. Where supported, the second uses an Oracle-style sequence.

<id name="id" type="long" column="cat_id">

<generator class="hilo">

<param name="table">hi_value</param>

<param name="column">next_value</param>

<param name="max_lo">100</param>

</generator>

</id>

<id name="id" type="long" column="cat_id">

<generator class="seqhilo">

<param name="sequence">hi_value</param>

<param name="max_lo">100</param>

</generator>

</id>

Unfortunately, you cannot use hilo when supplying your own Connection to Hibernate. When Hibernate uses an application server datasource to obtain connections enlisted with JTA, you must configure the hibernate.transaction.manager_lookup_class.



Most Viewed Articles (in Hibernate )

Latest Articles (in Hibernate)

Comment on this tutorial