ID Generator

If you wish to assign this issue/new feature to us, we can develop and
contribute to the Hibernate open source. 

Requirement:

1) Multiple UidGenerator streams (say a stream per table in DB)
2) High performance Requirement - Transaction spanning across public and
private network, end to end response time is 3 sec - Hence ID generation is
few m.sec
3) Unique identifier of type String / long / int
*       Say for example a particular DB table may need a String as the ID 
                                so the generator need to provide
Long.toString(long value);
*       Other tables may need a long or int.
4) Supporting multiple databases
5) Handle Transaction. 
*       (eg) 
*       Not participate in Transaction (when this is running in a session
bean)
*       Start new Transaction (when this is running in a session bean)
etc...
6) Use of high-low algorithm
7) Unique even in a multi-VM environment

hilo or seqhilo in Hibernate provides only a few out of the above 7
requirements. We need to have a new type that provides all the above.

Design:

Our generator will take a name as input (generatorName)
The generatorName parameter has to be a unique string, which allows
sequential blocks of unique ids to be kept within each class/DB table. This
provides the ability to have multiple UidGenerator streams.

Internally, key (long, 8bytes) generation is achieved using a so-called
high-low algorithm, obtaining the high values (also known as "blocks") from
a single persistent source (the UidBlockPool). Within a given block, IDs are
generated in memory. The persistent store is accessed only during startup
and when a block is exhausted. Depending on application requirement the
latter occurrence can  be very rare, if the block size is large enough. 

        Table Design :

        TABLE ES_UIDBLOCKPOOL
              NAME VARCHAR(50) NOT NULL
              BLOCK_SIZE LONGINT
              CURRENT_BLOCK LONGINT

Name is the generator name. (usually the name of the class that uses it)
The block size helps us to define custom block size. If sequential numbers
are needed, we could set the size to 1
Thus this makes it configurable. For each table we can set the custom block
size.
Current Block will have the current value for the Block for that particular
generator name.

The IDs are guaranteed to be unique even in a multi-VM environment, as long
as the persistent store is shared. IDs are not guaranteed to be sequential.
The generator provides unique ID that are either String or long or int based
on the request.
This could be configured in the same way as the existing ID generator in
Hibernate.

Advantages:

*       Custom block size could be set. So could be used as sequence
generator also.
*       It has all the features that we have in Increment, Sequence, Hilo in
Hibernate.
*       Multiple ID Streams 
*       High performance 


Regards,
P. Mukund.

-----------------------------------------
This email may contain confidential and privileged material for the sole use of the 
intended recipient(s). Any review, use, retention, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete all 
copies of this message.  Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive emails on the 
basis that we are not liable for any such corruption, interception, tampering, 
amendment or viruses or any consequence thereof.



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to