Yes - you'd implement a PkGenerator interface and set it on a
DbAdapter via 'setPkGenerator'.
http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/
dba/PkGenerator.html
A few hints:
* Cayenne already supports generating binary PKs without a DB trip -
just map your PK attribute as (VAR)BINARY, and this algorithm will
kick in automatically.
* You may subclass from one of the existing PkGenerators if you need.
* Most of the PkGenerator interface methods are intended for Modeler
integration. For the runtime you only need to implement
'generatePkForDbEntity(DataNode,DbEntity)'
* 'setPkGenerator' is not defined in the DbAdapter interface. So
you'd have to cast to concrete class to invoke it. If you use new
"auto-adapter" (the best choice when you don't know the target DB
flavor upfront), you'd have to wait for the next 1.2 milestone, (as I
just added this method today :-)), if you specify the adapter
explicitly, all known adapters inherit from JdbcAdapter that already
has this method.
Andrus
On Jan 16, 2006, at 10:46 PM, Dov Rosenberg wrote:
> We have a need to be able to generate our own primary keys without
> using a database specific solution. In our EOF based application we
> registered a DatabaseContext delegate class and implementing
> databaseContextNewPrimaryKey()
>
> Is there a parallel thing we can do with Cayenne?
This archive was generated by hypermail 2.0.0 : Mon Jan 16 2006 - 23:05:28 EST