objectId seems not populated when the pk=objectId and mapped in the modeler

From: Laszlo Spoor (lspoor_cayenn..otmail.com)
Date: Sun Jun 29 2003 - 07:21:09 EDT

  • Next message: Andrus Adamchik: "Re: objectId seems not populated when the pk=objectId and mapped in the modeler"

    Cayenne 1.0b4
    MySQL 4.12-max

    Hello Guys,

    I think I have noticed something strange. I am not sure if this is a bug,
    but I
    would like to have your opinion.

    If my object model in the cayenne modeler has no entry of the id (primary
    key
    of the entity) of the Photo Object. I can create and delete the persistance
    instance using the code below:

        DataContext mContext =
          
    Configuration.getSharedConfiguration().getDomain().createDataContext();

        Photo fto = (Photo)mContext.createAndRegisterNewObject("Photo");

        fto.setBestandsnaam("test.jpg");
        fto.setUrlPhoto("urlPhoto");
        fto.setUrlThumbnail("urlthumbnail");

        mContext.commitChanges(Level.WARN);

        ObjectId oi = fto.getObjectId();

        System.out.println("The object ID is: " +
    oi.getValueForAttribute("id"));

        mContext.deleteObject(fto);
        mContext.commitChanges(Level.WARN);

    However, if I do map the id in the modeler. The ObjectId will be null and
    this
    code throws a null pointer exception, when the object is to be deleted.

    If I just create the object and requery the datastore in another
    'application', the ObjectId is
    there.

    The workaround is not to map the id and 'resolve' the id when needed, but it
    seems a bit strange.

    Does anyone have an idea?

    Thanks, Laszlo

    _________________________________________________________________
    Add photos to your messages with MSN 8. Get 2 months FREE*.
    http://join.msn.com/?page=features/featuredemail



    This archive was generated by hypermail 2.0.0 : Sun Jun 29 2003 - 07:21:07 EDT