On 10/26/06, Roger Parkinson <roge..enanque.co.nz> wrote:
> Does anyone know how to do this?
> I know what I want to put in my key generator and I think it needs to
> implement PkGenerator (or possibly extend DbGenerator)
> So once I've done that how to I tell Cayenne to use it for all my primary
> keys?
Once you've done that, subclass the Adapter class you're working with
and implement createPkGenerator().
As an example, for OpenBase, I did this by creating
OpenBasePkGenerator.java, then in OpenBaseAdapter.java, I created:
protected PkGenerator createPkGenerator() {
return new OpenBasePkGenerator();
}
If I now wanted an application-specific pk generator, then I'd create
a CustomOpenBaseAdapter extends OpenBaseAdapter, and add:
protected PkGenerator createPkGenerator() {
return new CustomPkGenerator();
}
You can specify your adapter class in your nodes manually.
This archive was generated by hypermail 2.0.0 : Fri Oct 27 2006 - 10:54:09 EDT