What is the best way to provide a unique identifier as a primary key that will work in a database independent manner? I'm looking for functionality similar to Oracle's proprietary MY_SEQ.NEXTVAL.
1) For databases that support them, an insert trigger or stored procedure that uses a proprietary means such as MY_SEQ.NEXTVAL OR that uses one of the following methods.
2) Use a server socket whose job is to control and hand out new identifiers, either with proprietary means or one of the following.
4) Do the same as 3 in your own individual classes.
For 2), 3) and 4) either the supporting mechanism or your individual classes must be prepared to handle identifier clashes, since there is no way to guarantee that all database operations will use this mechanism in a production environment.
Other suggestions have included random numbers with checks for clashes and trying to generate a totally unique number internally. The problem with the last is complexity and the size of the generated key, which can impact performance.