> it looks like the IDBroker just returns one single int...is that a
> concatinated high/low value?

It just returns a simple int like a simple Oracle sequence.  We were
originally thinking of returning a high/low value but John and I decided it
wasn't necessary.

> in other words, if i want to use the features of the IDBroker, then what
> exactly do i need to have in my tables for the primary key?

We just stuck the PK in there so that all our tables would have a
non-business related key.  So you would just insert into ID_TABLE like:

insert into id_table (id_table_id, table_name, next_id, quantity)
 values (1, 'Permission', 1, 10);
insert into id_table (id_table_id, table_name, next_id, quantity)
 values (2, 'UserRole', 1, 10);
insert into id_table (id_table_id, table_name, next_id, quantity)
 values (3, 'Visitor', 1, 10);

Here's the comments.  Let me know if I missed anything or if you have
suggestions.

/**
 * This singleton mangages and allocates simple int IDs
 * on a per table basis.  This method of ID generation
 * is used to ensure that code is more database independent.
 * For example, mySQL has an auto-increment feature
 * while Oracle uses sequences.
 *
 * This class uses the table ID_TABLE defined in
 * docs/*_id_table.sql.  The columns in ID_TABLE are
 * used as follows:
 *
 * ID_TABLE_ID - the PK for this row (any unique int)
 * TABLE_NAME - the name of the table you want ids for
 * NEXT_ID - the next id returned by IDBroker when it
 *           queries the database (not when it returns an
 *           id from memory).
 * QUANTITY - the number of ids that IDBroker will cache
 *            in memory
 *
 * Use this class like this:
 * int id = IDBroker.getInstance().getNextId("TABLE_NAME");
 * int[] ids = IDBroker.getInstance().getNextIds("TABLE_NAME",
numOfIdsToReturn);
 *
 * NOTE: When the ID_TABLE must be updated we must
 * ensure that IDBroker objects running in different
 * JVMs do not overwrite each other.  Originally I was
 * thinking of locking tables on select/update but have
 * some other ideas now.
 *



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to