[JIRA] Created: (CAY-835) setting meaningful pk to zero turn on autogenerated keys

From: Tore Halset (JIRA) ("Tore)
Date: Mon Jul 30 2007 - 03:38:59 EDT

  • Next message: Andrus Adamchik: "Re: Unbound Entity (ObjEntity without DBEntity)"

    setting meaningful pk to zero turn on autogenerated keys
    --------------------------------------------------------

                     Key: CAY-835
                     URL: https://issues.apache.org/cayenne/browse/CAY-835
                 Project: Cayenne
              Issue Type: Bug
              Components: Cayenne Core Library
        Affects Versions: 3.0
             Environment: 3.0M1, derby, mac, java 5
                Reporter: Tore Halset
                Assignee: Tore Halset
                 Fix For: 3.0

    Having a table with a int primary key mapped to a Integer. Setting this value to Integer.valueOf(0) makes cayenne create its own primary key. So instead of value zero, the primary key will be 200 or whatever.

    Here is a test that shows this behaviour:
        public void testInsertWithMeaningfulPKValueZero() throws Exception {
            Integer zero = new Integer(0);
            MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
                    .newObject("MeaningfulPKTest1");
            obj.setPkAttribute(zero);
            obj.setDescr("aaa-aaa-bbb");
            context.commitChanges();
            assertEquals(zero, obj.getPkAttribute());
            ObjectIdQuery q = new ObjectIdQuery(new ObjectId(
                    "MeaningfulPKTest1",
                    MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN,
                    zero.intValue()), true, ObjectIdQuery.CACHE_REFRESH);
            assertEquals(1, context.performQuery(q).size());
        }

    -- 
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
    



    This archive was generated by hypermail 2.0.0 : Mon Jul 30 2007 - 03:39:26 EDT