cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emanuele Maiarelli <emanu...@mengozzi.com>
Subject Re: Possible bug in cayene 3.0.2 to set relationships???
Date Tue, 23 Oct 2012 15:55:12 GMT
  

Did you specify the primary key generation strategy? 

As far as i
remember i had similar errors on oracle dued to not having specified the
sequence name(and cached size) 

On Tue, 23 Oct 2012 13:57:50 +0200,
Felipe Martín Santos wrote: 

> Sorry but doesn' work :-(
> 
> MY
RELATIONSHIPS:
> 
> db-attribute-pair source="ID_PIECE_OF_GROUND"
target="ID_PIECE_OF_GROUND"/>
> 
>
*********************************************
> THE CODE FOR INSERT (We
use Generic Persistent Class of Cayenne)
> 
> Expression exp =
ExpressionFactory.matchExp("idPieceOfGround", "123673");
> SelectQuery
query = new SelectQuery("PieceOfGround", exp);
> List pieceOfGround =
context.performQuery(query);
> 
> exp =
ExpressionFactory.matchExp("cdUse", 5990403);
> query = new
SelectQuery("Use", exp);
> List use = context.performQuery(query);
> 
>
DataObject enclosure = new CayenneDataObject();
>
enclosure.setObjectId(new ObjectId("Enclosure"));
> 
> // Set de
DataObject for the relationships
>
enclosure.writeProperty("toPieceOfGround", pieceOfGround.get(0));
>
enclosure.writeProperty("toUse", use.get(0));
> 
>
context.registerNewObject(arbol);
> context.commitChanges();
> 
>
*************************************
> MY CONCLUSIONS
> 
> cayenne
context.commitChanges() builds automatically the insert:
> 
> *
ID_PIECE_OF_GROUND is pk in PIECE_OF_GROUND: when I do
>
enclosure.writeProperty("toPieceOfGround", pieceOfGround.get(0)), in
the
> commit moment, cayenne can extract automatically the
ID_PIECE_OF_GROUND for
> the pieceOfGround DataObject, and put this
value as insert parameter.
> 
> * CD_USE is NOT pk in USE: when I do
enclosure.writeProperty("toUse",
> use.get(0)), in the commit moment,
cayenne CAN´T extract automatically the
> CD_USE for the use DataObject,
and can´t put this value as insert parameter.
> 
> I think the problem
is that, "a bug" or a cayenne design issue not taken.
> 
>
****************************************************************************
>

> In the db-entity PIECE_OF_GROUND I can't put
> 
> as PK, because its
PK is ID_PIECE_GROUND (Autogenerated by cayenne with an
> Oracle
sequence) and if I include CD_USE as PK cayenne fails
>
(org.apache.cayenne.CayenneRuntimeException: [v.3.0.2 Jun 11 2011
09:26:09]
> Primary Key autogeneration only works for a single
attribute.).
> 
> I've tried all the possible combinations tha you've
said me, but none works
> :-)
> 
> Andrus, you can test this probleme if
you have a similar example (more or
> less), and check what I say.
> 
>
Thank you very much for your attention!!

-- 

  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message