public class SequenceManagerStoredProcedureImpl extends AbstractSequenceManager
SequenceManagerStoredProcedureImpl
implementation enabled database
sequence key generation for all databases (e.g. MSSQL, MySQL, DB2, ...)
with a JDBC 2.0 compliant driver.
OJB_NEXTVAL_SEQ
to
your database.
CREATE TABLE OJB_NEXTVAL_SEQ ( SEQ_NAME VARCHAR(150) NOT NULL, MAX_KEY BIGINT, CONSTRAINT SYS_PK_OJB_NEXTVAL_SEQ PRIMARY KEY(SEQ_NAME) )You will also need the stored procedure OJB_NEXTVAL will will take care of giving you a guaranteed unique sequence number, in multi server environments.
CREATE PROCEDURE ojb_nextval_proc @SEQ_NAME varchar(100) AS declare @MAX_KEY BIGINT -- return an error if sequence does not exist -- so we will know if someone truncates the table set @MAX_KEY = 0 UPDATE OJB_NEXTVAL_SEQ SET @MAX_KEY = MAX_KEY = MAX_KEY + 1 WHERE SEQ_NAME = @SEQ_NAME if @MAX_KEY = 0 select 1/0 else select @MAX_KEY RETURN @MAX_KEY
sequence-name
field-descriptor attribute in the repository file. If
such an attribute was not found, the implementation build
an extent aware sequence name by its own.
sequence-name
for all extents.
Implementation configuration properties:
Property Key | Property Values |
autoNaming |
Default was 'true'. If set 'true' OJB try to build a
sequence name automatic if none found in field-descriptor
and set this generated name as sequence-name
in field-descriptor. If set 'false' OJB throws an exception
if none sequence name was found in field-descriptor.
|
Limitations:
PROPERTY_AUTO_NAMING
Constructor and Description |
---|
SequenceManagerStoredProcedureImpl(PersistenceBroker broker)
Constructor
|
afterStore, calculateSequenceName, getBrokerForClass, getConfigurationProperties, getConfigurationProperty, getPlatform, getUniqueValue, setConfigurationProperties, setConfigurationProperty, setReferenceFKs, useAutoNaming
public SequenceManagerStoredProcedureImpl(PersistenceBroker broker)
broker
- (C) 2002 - 2005 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30