Re: Object Validation Auto Increment Problem

From: Michael Gentry (mgentr..asslight.net)
Date: Thu Jun 18 2009 - 11:39:05 EDT

  • Next message: Michael Shea: "Re: Foreign key constraint problem."

    I'm going to take a guess that the isMandatory="true" is firing first
    before the PK is generated and assigned. Try turning that off and see
    if it works. Cayenne should know that PKs are mandatory, anyway.

    mrg

    On Wed, Jun 17, 2009 at 5:17 PM, Mark Fraser<mar..ark100.net> wrote:
    > Hello,
    >
    > I am using Cayenne 2.0.4 with Derby embedded.
    >
    > I am getting a ValidationException "id is required" when I commit changes
    > after creating a new object.
    >
    > I have set the PK Generation Strategy to Database-Generated and set the ID
    > field as Auto Incremented in the modeler.
    >
    > In my map file the id field looks like this:
    >
    > ...db-attribute name="ID" type="INTEGER" isPrimaryKey="true"
    > isGenerated="true" isMandatory="true" length="10"....
    >
    >
    > I have also tested whether Cayenne thinks the adapter supports generated
    > keys with the following code:
    >
    >
    >   DataMap map = dataContext.getEntityResolver().getDataMap("MyMap");
    >   DataNode node = dataContext.getParentDataDomain().lookupDataNode(map);
    >   DbAdapter ad = node.getAdapter();
    >   System.out.println(ad.supportsGeneratedKeys());
    >  and this returns true.
    >
    > If I uncheck "Object Validation" for the data domain in the modeler
    > everything works fine.
    >
    > However I would rather not turn off object validation.
    >
    > Anyone have any suggestions on what I might be missing?
    >
    > Thanks,
    >
    > Mark
    >



    This archive was generated by hypermail 2.0.0 : Thu Jun 18 2009 - 11:40:00 EDT