cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felipe Martín Santos <gadita...@gmail.com>
Subject Possible bug in cayene 3.0.2 to set relationships???
Date Mon, 22 Oct 2012 10:28:26 GMT
We work with Cayenne 3.0.2 and we handle the PK with Cayenne Generated PK
(an Oracle Sequence).

The tables are as follows (To abbreviate, I don’t included the sequence
name)



<db-entity name=*"ENCLOSURE"* schema=*"FIELD"*>

<db-attribute name=*"ID_RECINTO"* type=*"NUMERIC"* isPrimaryKey=*"true"*
isMandatory=*"true"* length=*"12"*/>

      <db-attribute name=*"CD_USE"* type=*"VARCHAR"* isMandatory=*"true"*
length=*"2"*/>

      <db-attribute name=*"ID_PIECE_OF_GROUND"* type=*"NUMERIC"* length=*
"12"*/>

</db-entity>







<db-entity name=*"USE"* schema=*"FIELD"*>

            <db-attribute name=*"ID_USO_SIGPAC"* type=*"NUMERIC"*
isPrimaryKey=*"true"* isMandatory=*"true"* length=*"12"*/>

            <db-attribute name=*"CD_USE"* type=*"VARCHAR"* isMandatory=*
"true"* length=*"2"*/>  /* Isn’t PK but is UNIQUE */

            <db-attribute name=*"DS_USE"* type=*"VARCHAR"* isMandatory=*
"true"* length=*"50"*/>

</db-entity>





<db-entity name=*"PIECE_OF_GROUND"* schema=*"FIELD"*>

            <db-attribute name=*"ID_PIECE_OF_GROUND"* type=*"NUMERIC"*
isPrimaryKey=*"true"* isMandatory=*"true"* length=*"12"*/>

            <db-attribute name=*"DS_PIECE_OF_GROUND"* type=*"VARCHAR"*
isMandatory=*"true"* length=*"50"*/>

</db-entity>



<db-relationship name=*"toUse"* source=*"ENCLOSURE"* target=*"USE"* toMany=*
"false"*>

            <db-attribute-pair source=*"CD_USE"* target=*"CD_USE"*/>

</db-relationship>



<db-relationship name=*"toField"* source=*"ENCLOSURE"* target=*
"PIECE_OF_GROUND"* toMany=*"false"*>

            <db-attribute-pair source=*"ID_PIECE_OF_GROUND"* target=*
"ID_PIECE_OF_GROUND"*/>

</db-relationship>





The PIECE_OF_GROUND PK is the ENCLOSURE FK (ID_PIECE_OF_GROUND)

The USE is a parametric table. The CD_USE  isn’t PK, but it’s UNIQUE, and
we use this for the relationship with  the CD_USE FK in the ENCLOSURE table.



When we create a new Enclosure object, we perform the following steps:



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.



When I commit against the database, we get the next error:



org.apache.cayenne.CayenneRuntimeException: [v.3.0.2 Jun 11 2011 09:26:09]

Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: can
not perform an insert  NULL en ("FIELD"."USE"."CD_USE")


The problem is: if I relate two tables with the pair FK-PK Cayenne works
well (ex: the ID_PIECE_OF_GROUND has an value for the INSERT), but if the
relationship is between FK-(An UNIQUE field), cayenne can’t extract de
value (ex: the CD_USE is null for the INSERT) . How it’s possible?? It’s a
bug?

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