cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kienenberger" <>
Subject Re: Custom key generator?
Date Fri, 27 Oct 2006 14:53:38 GMT
On 10/26/06, Roger Parkinson <> 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, then in, 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.

View raw message