You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Felipe Martín Santos (JIRA)" <ji...@apache.org> on 2012/10/23 17:59:12 UTC

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

Felipe Martín Santos created CAY-1751:
-----------------------------------------

             Summary: 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 + Oracle 10g Database
            Reporter: Felipe Martín Santos
            Priority: Minor
             Fix For: 3.1 (final), 3.0.2


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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felipe Martín Santos updated CAY-1751:
--------------------------------------

    Attachment:     (was: FieldDomainNode.driver.xml)
    
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>         Attachments: 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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felipe Martín Santos updated CAY-1751:
--------------------------------------

    Attachment: FieldDomainMap.map.xml
    
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>         Attachments: 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

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

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13484392#comment-13484392 ] 

Andrus Adamchik commented on CAY-1751:
--------------------------------------

So I created a 3.1 project based on your 3.0 mapping (the parts we are talking about should be compatible), and switched from Oracle to Derby to simplify my environment. The error is reproducible in this setup...  Next I did a small fix to the test, registering object before setting its relationship. Doesn't make much difference here I think, but just a good practice in general:

@@ -103,12 +104,10 @@ public class Main {
             DataObject treeType = treeTypes.get(0);
             DataObject enclosure = enclosures.get(0);
 
-            DataObject fruitTree = new CayenneDataObject();
-            fruitTree.setObjectId(new ObjectId("FruitTree"));
+            DataObject fruitTree = (DataObject) context.newObject("FruitTree");
             fruitTree.writeProperty("plantingDate", new Date());
             fruitTree.writeProperty("toEnclosure", enclosure);
             fruitTree.writeProperty("toTreeType", treeType);
-            context.registerNewObject(fruitTree);


At this point the error is still reproducible. Finally I changed the mapping to add "fake" PKs to 2 entities and specify which side is the master, and which is dependent:

diff --git a/src/main/resources/FieldDomainMap.map.xml b/src/main/resources/FieldDomainMap.map.xml
index e76fd96..530f8b2 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" isMandatory="true" length="3"/>
+		<db-attribute name="CODE_TYPE_TREE" type="NUMERIC" isPrimaryKey="true" 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"/>
@@ -24,7 +24,7 @@
 		</db-key-generator>
 	</db-entity>
 	<db-entity name="TREE_TYPES">
-		<db-attribute name="CODE_TYPE_TREE" type="NUMERIC" isMandatory="true" length="3"/>
+		<db-attribute name="CODE_TYPE_TREE" type="NUMERIC" isPrimaryKey="true" isMandatory="true" length="3"/>
 		<db-attribute name="DESCRIPTION_TYPE_TREE" type="VARCHAR" length="30"/>
 		<db-attribute name="ID_TREE_TYPE" type="NUMERIC" isPrimaryKey="true" isMandatory="true" length="12"/>
 		<db-key-generator>
@@ -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" toMany="true">
+	<db-relationship name="toFruitTree" source="TREE_TYPES" target="FRUIT_TREES" toDependentPK="true" 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"/>
-- 

This fixed the problem. The following SQL is generated in the last commit:

INFO: INSERT INTO "FRUIT_TREES" ("CODE_TYPE_TREE", "ID_ENCLOSURE", "ID_FRUIT_TREES", "PLANTING_DATE") VALUES (?, ?, ?, ?)
INFO: [batch bind: 1->CODE_TYPE_TREE:1, 2->ID_ENCLOSURE:200, 3->ID_FRUIT_TREES:200, 4->PLANTING_DATE:'2012-10-25 22:13:46.071']
                
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>         Attachments: 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

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

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik closed CAY-1751.
--------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 3.1 (final))
                       (was: 3.0.2)

Closing this, as we have a workaround. Going forward we may need to improve "native" handling to value propagation across relationships between non-pk columns 
                
> 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, 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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486110#comment-13486110 ] 

Felipe Martín Santos commented on CAY-1751:
-------------------------------------------

Ok, I've tested with both: the proposed example and my real code... Now I can insert records in the database. :-) Thank you very very very much....

But now I've a problem when I get a FruiTree Object from the database. If I navigate to Enclosure.... There's not a problem, but when I navigate to TreeTypes.... ERROR oooooops!!

Here the code:

SelectQuery treeQuery = new SelectQuery("FruitTree");
List<DataObject> trees = context.performQuery(treeQuery);
           
DataObject tree = trees.get(0);
           
DataObject enclosure = (DataObject)tree.readProperty("toEnclosure");
Object description = enclosure.readProperty("descriptionEnclosure");

DataObject treeType = (DataObject)tree.readProperty("toTreeType");
Object codeTreeType = treeType.readProperty("codeTypeTree"); // here comes the error
Object descriptionTreeType = treeType.readProperty("descriptionTypeTree");


org.apache.cayenne.FaultFailureException: [v.3.0.2 Jun 11 2011 09:26:09] Error resolving fault for ObjectId: <ObjectId:TreeType, CODE_TYPE_TREE=1> and state (hollow). Possible cause - matching row is missing from the database.
    at org.apache.cayenne.BaseContext.prepareForAccess(BaseContext.java:171)
    at org.apache.cayenne.CayenneDataObject.readProperty(CayenneDataObject.java:219)
    at org.apache.cayenne.CayenneDataObject.readSimpleProperty(CayenneDataObject.java:203)
    at org.apache.cayenne.CayenneDataObject.readNestedProperty(CayenneDataObject.java:132)
    at org.apache.cayenne.CayenneDataObject.readNestedProperty(CayenneDataObject.java:154)
    at es.juntadeandalucia.agapa.gis.ide.dataset.sigpac.test.FruitTest.test(FruitTest.java:150)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
                
> 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, 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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felipe Martín Santos reopened CAY-1751:
---------------------------------------


problems when I get the object inserted before.
                
> 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, 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

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

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
     [ 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

attaching a full local git repo and the 3.1 Eclipse project
                
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>         Attachments: 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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felipe Martín Santos updated CAY-1751:
--------------------------------------

    Attachment: FruitTest.java
                fruits.sql
                FieldDomainNode.driver.xml
                FieldDomainMap.map.xml
                cayenne.xml

in the fruits.sql I added 2 lines that CayenneModeler doesn't include automatically.

thanks for all!!
                
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>         Attachments: 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

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

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
     [ 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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felipe Martín Santos updated CAY-1751:
--------------------------------------

    Environment: Eclipse + Java 5 + Junit + Cayenne 3.0.2 (Generic Persistent Class) + Oracle 10g Database  (was: Eclipse + Java 5 + Junit + Cayenne 3.0.2 + Oracle 10g Database)
    
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>
> 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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felipe Martín Santos updated CAY-1751:
--------------------------------------

    Attachment:     (was: FieldDomainMap.map.xml)
    
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>         Attachments: 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

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

Posted by "Felipe Martín Santos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felipe Martín Santos updated CAY-1751:
--------------------------------------

    Attachment: FieldDomainNode.driver.xml
    
> 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
>             Fix For: 3.0.2, 3.1 (final)
>
>         Attachments: 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