I'm back.

I created object attributes for 3 foreign keys. Example for one of them:

    public void setStreetId(Integer streetId) {
        writeProperty("streetId", streetId);
    }
    public Integer getStreetId() {
        return (Integer)readProperty("streetId");
    }

and now instead of setting the relationship:

    houseNumber.setStreet(localStreet);

I do:

    houseNumber.setStreetId(streetMid);

But now I am getting

Validation failure for com.acme.maps.model.HouseNumber.street: "street"  is
required.

Nowhere in the mapping file or in the modeler there is an option to set the
optionality of the relationship, only for attributes. Why am I getting this
validation message?

At the database level, the FK attribute is set to "NOT NULL", but this is
not related with the Cayenne.

Hints?

-Borut


2010/10/20 Andrus Adamchik <[email protected]>

>
> On Oct 19, 2010, at 10:36 AM, Borut Bolčina wrote:
>
> > This way using
> >
> > street.setTown(localTown);
> >
> > does not set the relationship, it inserts NULL for town_id FK in the
> streets
> > table. Or did you mean something else?
>
>
> Probably (?) didn't quite get the explanation of your mapping. Anyways,
> have you tried setting meaningful FK, mapped as an ObjAttribute?
>
> Andrus
>
>

Reply via email to