Ok Andrus, I've discovered how attach files...

When you have a free moment, check it out please, if you have troubles
understanding something... ask me!!

Best regards!!

2012/10/23 Felipe Martín Santos <gadita...@gmail.com>

> Muchísimas gracias Andrus!!
>
> I've created https://issues.apache.org/jira/browse/CAY-1751
>
> is possible upload a file? or I must write the code in the Description
> Frame??
>
>
>
>
> 2012/10/23 Andrus Adamchik <and...@objectstyle.org>
>
>> > Andrus, you can test this probleme if you have a similar example (more
>> or
>> > less), and check what I say.
>>
>>
>> Yes, if you can provide a mapping project demonstrating an issue (no need
>> for Java classes), I'll take a look. Feel free to use our Jira for that:
>>
>> https://issues.apache.org/jira/browse/CAY
>>
>> Andrus
>>
>>
>> On Oct 23, 2012, at 2:57 PM, Felipe Martín Santos <gadita...@gmail.com>
>> wrote:
>>
>> > Sorry but doesn' work :-(
>> >
>> > MY RELATIONSHIPS:
>> >
>> > <db-relationship name="toUse" source="ENCLOSURE" target="USE"
>> > toMany="false">
>> > <db-attribute-pair source="CD_USE" target="CD_USE"/>
>> > </db-relationship>
>> >
>> > <db-relationship name="toPieceOfGround" source="ENCLOSURE"
>> > target="PIECE_OF_GROUND" toMany="false">
>> > db-attribute-pair source="ID_PIECE_OF_GROUND"
>> target="ID_PIECE_OF_GROUND"/>
>> > </db-relationship>
>> >
>> > <obj-relationship name="toPieceOfGround" source="Enclosure"
>> > target="PieceOfGround" deleteRule="Nullify"
>> > db-relationship-path="toPieceOfGround"/>
>> >
>> > <obj-relationship name="toUse" source="Enclosure" target="Use"
>> > deleteRule="Nullify" db-relationship-path="toUse"/>
>> >
>> > *********************************************
>> > THE CODE FOR INSERT (We use Generic Persistent Class of Cayenne)
>> >
>> > Expression exp = ExpressionFactory.matchExp("idPieceOfGround",
>> "123673");
>> > SelectQuery query = new SelectQuery("PieceOfGround", exp);
>> > List<DataObject> pieceOfGround = context.performQuery(query);
>> >
>> > exp = ExpressionFactory.matchExp("cdUse", 5990403);
>> > query = new SelectQuery("Use", exp);
>> > List<DataObject> 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
>> > <db-attribute name="CD_USE" type="VARCHAR" isMandatory="true"
>> length="2">
>> > 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!!
>>
>>
>

Reply via email to