Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-835

setting meaningful pk to zero turn on autogenerated keys

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.0M2
    • Core Library
    • None
    • 3.0M1, derby, mac, java 5

    Description

      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()); }

      Attachments

        Activity

          People

            Unassigned Unassigned
            halset Tore Halset
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: