You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2012/11/01 23:10:12 UTC

[jira] [Updated] (CAY-1751) FK pointing to an UNIQUE field. Problems to insert registers

     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik updated CAY-1751:
---------------------------------

    Attachment: cay1751.tar.gz

I fixed the FaultFailureException per CAY-1755. This was a bug indeed. The fix is available in Subversion on trunk (3.2) and STABLE-3.1 branches. 

Also attaching a new git repo with the test code. It simplifies the hack that did before - the fruittree FK doesn't have to be mapped as a fake PK:

diff --git a/src/main/resources/FieldDomainMap.map.xml b/src/main/resources/FieldDomainMap.map.xml
index 530f8b2..f508af6 100644
--- a/src/main/resources/FieldDomainMap.map.xml
+++ b/src/main/resources/FieldDomainMap.map.xml
@@ -14,7 +14,7 @@
                </db-key-generator>
        </db-entity>
        <db-entity name="FRUIT_TREES">
-               <db-attribute name="CODE_TYPE_TREE" type="NUMERIC" isPrimaryKey="true" isMandatory="true" length="3"/>
+               <db-attribute name="CODE_TYPE_TREE" type="NUMERIC" isMandatory="true" length="3"/>
                <db-attribute name="ID_ENCLOSURE" type="NUMERIC" isMandatory="true" length="12"/>
                <db-attribute name="ID_FRUIT_TREES" type="NUMERIC" isPrimaryKey="true" isMandatory="true" length="12"/>
                <db-attribute name="PLANTING_DATE" type="DATE" isMandatory="true"/>
@@ -51,7 +51,7 @@
        <db-relationship name="toTreeType" source="FRUIT_TREES" target="TREE_TYPES" toMany="false">
                <db-attribute-pair source="CODE_TYPE_TREE" target="CODE_TYPE_TREE"/>
        </db-relationship>
-       <db-relationship name="toFruitTree" source="TREE_TYPES" target="FRUIT_TREES" toDependentPK="true" toMany="true">
+       <db-relationship name="toFruitTree" source="TREE_TYPES" target="FRUIT_TREES" toMany="true">
                <db-attribute-pair source="CODE_TYPE_TREE" target="CODE_TYPE_TREE"/>
        </db-relationship>
        <obj-relationship name="toFruitTree" source="Enclosure" target="FruitTree" db-relationship-path="toFruitTree"/>


                
> FK pointing to an UNIQUE field. Problems to insert registers
> ------------------------------------------------------------
>
>                 Key: CAY-1751
>                 URL: https://issues.apache.org/jira/browse/CAY-1751
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Core Library, Database integration
>    Affects Versions: 3.0.2
>         Environment: Eclipse + Java 5 + Junit + Cayenne 3.0.2 (Generic Persistent Class) + Oracle 10g Database
>            Reporter: Felipe Martín Santos
>            Priority: Minor
>              Labels: features, patch
>         Attachments: cay1751.tar.gz, cay1751.tar.gz, cayenne.xml, FieldDomainMap.map.xml, FieldDomainNode.driver.xml, fruits.sql, FruitTest.java
>
>
> I need insert a new record and the table where insert have 2 FK not null:
> If I relate TABLE_A (FK) with TABLE_B (PK)  Cayenne works well but if the relationship is between TABLE_A (FK)  with TABLE_C (An UNIQUE field), cayenne can´t extract de value of that UNIQUE value, and the insert sentence generated live that field null and I get next error:
> java.sql.SQLIntegrityConstraintViolationException: ORA-01400. Can not perform an insert NULL

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira