Hi Dirk,
That was just a quick shot. It is just a static method
that is internally used to generate unique filenames
to be used with diskblobs. It simply concatenates the current timestamp
with a random number. If we want to use that within an application,
it must be via an interceptor...
public static String getUniqueID() {
long first = new java.util.Date().getTime();
int second = (int) (Math.random()*100);
return Long.toString(first) + Integer.toString(second);
}
Maybe it would be not bad to have a standard mechanism to be able to generate these keys within dbforms. Maybe offering severalor The HIGH/LOW Approach To OIDs by Scott Ambler ?
algorithms like:
- timestamp + random value as above - maximum value + 1
- table maintained value using a table having columns
(catalog,schema,table,column,currentMaimumKeyValue)
http://www.ambysoft.com/mappingObjects.pdf
http://www.mail-archive.com/jdbforms-interest@;lists.sourceforge.net/msg00052.html
Anyway, If anyone is interested, there is some code at
http://www.pow2.com/download/pow2toolkit_20020926.zip
See the com.pow2.dao.IdGenerator source.
Requirements: a database table like this:
CREATE TABLE "app_identifier"
(
"id" integer NOT NULL,
"high" integer,
Constraint "app_identifier_pkey" Primary Key ("id")
);
Problems:
a)
every insert operation should use the id generator method
that uses the table above ;^)
If you add new records into a table "by hand", you could increment the max id value for all the tables without update the "high" field value of the "app_identifier" table.
So there is the possibility to create an insert statement with a duplicate key 8^(
RegardsDirk
Regards, Luca ------------------------------------------------------- This SF.net email is sponsored by: ApacheCon, November 18-21 in Las Vegas (supported by COMDEX), the only Apache event to be fully supported by the ASF. http://www.apachecon.com _______________________________________________ DbForms Mailing List http://www.wap-force.net/dbforms
