HiLo Key Generator
Configuration attributes
TableName
The name of the table used to store sequence names and their highest Hi values.
SequenceColumn
The name of the column in the table that is used to store a name of a sequence.
IdColumnName
The name of the column in the table that is used to store the highest Hi value of a sequence.
CreateTableDdl
The DDL statement that will be used to create the table in the database when the service starts and CreateTable attribute is set to true.
CreateTable
Can be true or false. If set to true and the table doesn't exist in the database yet, the table will be created using the DDL statement specified in the CreateTableDdl attribute. If set to false, the table is assumed to exist in the database.
DropTable
Can be true or false. If set to true and the table exists in the database, the table will be dropped when the service stops, e.g. at undeploy/redeploy time or server restart.
SelectHiSql
This attribute is optional. If not set then the last Hi value will be stored in the KeyGenerator's highestHi static variable. When a generator is exhausted and needs to refresh its Hi value, the value of this static variable will be used as the current highest Hi value. Of course, this approach doesn't work in a cluster.
To make the service work in a cluster, you should set SelectHiSql to an SQL statement that selects the highest Hi value of the sequence. FOR UPDATE at the end of the query is recommended.
FactoryName
The JNDI name the KeyGeneratorFactory service will be bound to.
SequenceName
The name of the sequence.
BlockSize
HiLo block size.
Logging
To see TRACE logging from the service which includes SQL and DDL statements executed, enable TRACE threshold for category
org.jboss.ejb.plugins.keygenerator.hilo
in the log4j.xml.
Comments