cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Possible bug in cayene 3.0.2 to set relationships???
Date Tue, 23 Oct 2012 10:15:07 GMT
Looking at it again, I think you need to make both USE.CD_USE and ENCLOSURE.CD_USE columns
PKs in Cayenne model. On the ENCLOSURE side, you'd keep an ObjAttribute for this newly designated
PK column (so your Java could would stay the same, and you'll keep calling 'setUse').

Of course this shouldn't affect your PK definitions in the DB. Only in the Cayenne model.


On Oct 23, 2012, at 11:36 AM, Felipe Martín Santos <> wrote:

> Thank you very much Andrus, but your solution doesn't work. I still believe
> that is a debug of cayenne.
> To do that you've said me:
> * To allow the Cayenne modeler check "to dep Pk" in the relationship
> slave_table (ENCLOSURE) --> master_table (USE), I need before check the FK
> (CD_USE)  in the slave_table, and so I can alredy select the check "to dep
> Pk".
> But now i've another problem. I use Cayenne-Generated Primary Key, and when
> I generate a new CayenneDataObject() type Enclosure:
>> 1. Create and register a new Enclosure object in our Cayenne DataContext.
>> 2. Retrieve from the database an  “Use” DataObject, an setUse in the
>> Enclosure Object
>> 3. Retrieve from  the database an “PieceOfGround” DataObject and
>> setPieceOfGround in the Enclosure Objet.
> I get this error:
> org.apache.cayenne.CayenneRuntimeException: [v.3.0.2 Jun 11 2011 09:26:09]
> Primary Key autogeneration only works for a single attribute.
> ... Before do this changes I expected that error because the pk
> autogeneration only works wiht single values.....
> I still think that is a cayenne problem or bug, because it doesn't allows
> to have a fk to a unique field, must always be to a pk field :-(

View raw message