> Do you have an example how to use UniqueIDGenerator?
>
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);
}
Just to summarize the problems with dbms maintained keys:
1) not supported by all dbms, makes application less portable
2) another problem with these dbms maintained keys is that before JDBC3
there is no standard way to get the value from the last inserted
row. Dbforms knows that the value will be generated by dbms, so
leaves it as null. After inserting the row, the key value is
not set and the attempt to navigate to the new inserted row
results in a NPE (unknown key value).
Maybe it would be not bad to have a standard mechanism to be
able to generate these keys within dbforms. Maybe offering several
algorithms like:
- timestamp + random value as above
- maximum value + 1
- table maintained value using a table having columns
(catalog,schema,table,column,currentMaimumKeyValue)
and within config:
<field name="id" type="integer" dbFormsMaintainedAutoInc="true"
autoIncAlgorithm="timestampPlusRandom" />
That way the application would even be able to run with a dbms
supporting no autoInc keys.
However, for a portable example application a simple solution
using an interceptor could be sufficient. I would also avoid the NPE....
Regards
Dirk
-------------------------------------------------------
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