Object Validation Auto Increment Problem

From: Mark Fraser (mar..ark100.net)
Date: Wed Jun 17 2009 - 17:17:51 EDT

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


    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();
    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?



    This archive was generated by hypermail 2.0.0 : Wed Jun 17 2009 - 17:18:31 EDT