Clouds
Home

Hibernate 2.0 Introduction

Hibernate Mapping Declaration

Hibernate Development Code

Hibernate Generator

Inheritence Mapping

Hibernate Generator


Increment

The encrement generator is probably the most familier creator of IDs.Each time the generator needs to generate an ID,it performs a select on current database,determines the current largest ID value,and increment of next value.

Syntax:

<generator class="increment"/>

Idendity

If the database has identity column associated with it.

Syntax:

<generator class="identity" >
    <param name="identity">identity_name</param>
</generator>

Sequence

If the database has sequence column associated with it.

Syntax

<generator class="sequence">
    <param name="sequence">seq_name</param>
</generator>

Hilo

It generates unique IDs for database table.The IDs won’t necessarily be sequencial.The generator must have access to secondary table.The default table is hibernate-unique-key and required column is next-value.We need to insert one row in the table as below example.

Example

create table hibernate-unique-key( next-value int);
insert into hibernate-unique-key values(100);

Syntax

<generator class="hilo"/> //it will use hibernate-unique-key table
<generator class="hilo">
<param name="table">TABLE_NAME</param>
<param name="column">COLUMN_NAME</param>
<param name="max to">500</param>
</generator>

Seqhilo

It is combination of hilo generator.

Syntax

<generator class="seqhilo">
    <param name="sequence">SEQ_NAME</param>
    <param name="max_lo">1000</param>
</generator>

Uuid.hex

This generates a unique value based on appending the following values:IP Address,the startup time of current JVM,the current time,and counter value.It support all database and has no paameter.possible column types are string,varchar,and text

Syntax

<generator class="Uuid.hex" />

Uuid.string

It works like Uuid.hex but the result is a string 16 charactors long.

Syntax

<generator class="Uuid.string" />

Native

It picks identity,sequence,or hilo,depending on the database.

Syntax

<generator class="native"/>

Assigned

If you need to assign the identifier youself in application,then use the assigned generator.

Syntax

<generator class="assigned"/>

<<<< PREVIOUS: Hibernate Development Code          NEXT: Hibernate Inheritance Mapping >>>>


Home Clouds