On Feb 23, 2005, at 8:36 PM, Roman D wrote:
> Final question;
> Which approach would you recommend for DB-independent design? I mean
> Generated vs AUTO_PK_SUPPORT ? (I guess "Generated" will have better
> performance than AUTO_PK_SUPPORT)
Not necessarily - PkGenerator caches whole PK ranges in memory, so
there is no clear advantage in performance either way.
> If "Generated" is used and DB doesn't support sequences, will Cayenne
> automatically use AUTO_PK_SUPPORT ?
Lets make sure that we are using the same terminology:
* "Sequences" are standalone database objects with special behavior,
supported by some DBs. Sequences are separate from the tables.
Sequences are one of the mechanisms (another being AUTO_PK_SUPPORT)
under "Cayenne-Generated Primary Key" category.
* "Generated" flag describes a different situation - "autoincrement" or
"identity" columns, i.e. columns that increment their value
automatically when a new row is inserted [different DB vendors call
these things different names, adding to the confusion, but the point is
that this mechanism is built in a DB table, and most importantly - the
value is passed back to java via JDBC API]. This falls under
"Database-Generated Primary Key" category.
So I rephrase the whole strategy in terms of Cayenne:
Primary key generation is first attempted using "Database-Generated
Primary Key" mechanism. If either (a) "generated" checkbox is not
checked for PK column of a given table in CayenneModeler or (b) this
feature is not supported by the target DB or JDBC driver, then Cayenne
falls back to "Cayenne-Generated Primary Key" strategy. The later is
determined by default (or custom) PkGenerator installed on a given
DbAdapter.
Definitely adding "generated" keys to the mix in 1.2 resulted in some
confusion (esp. since this is new and not well documented), however the
general approach is very simple, and in most cases it "just works"
without any special configuration.
Andrus
This archive was generated by hypermail 2.0.0 : Wed Feb 23 2005 - 23:47:59 EST