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

Custom types used for PK are causing grief in relationships

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1B1, 3.2.M1
    • None
    • Core Library
    • None

    Description

      1. Map an entity with meaningful PK, type of that PK being a non-standard type for a given type of column (e.g. attached test case demonstrating the problem maps a VARCHAR column to java.util.UUID).
      2. Map another entity with an FK to the first entity, and create a to-one relaionship.
      3. Fetch entity 2 and try to read the relationship to entity 1. The result is a FaultFailureException similar to this one:

      org.apache.cayenne.FaultFailureException: [v.3.2M1-SNAPSHOT ${project.build.date} ${project.build.time}] Error resolving fault for ObjectId: <ObjectId:UuidPkEntity, ID=8251ae98-de42-404c-9cd0-9c1b29410604> and state (hollow). Possible cause - matching row is missing from the database.
      at org.apache.cayenne.BaseContext.prepareForAccess(BaseContext.java:316)
      at org.apache.cayenne.CayenneDataObject.readProperty(CayenneDataObject.java:174)
      at org.apache.cayenne.testdo.testmap.auto._UuidPkEntity.getId(_UuidPkEntity.java:26)
      at org.apache.cayenne.access.UUIDTest.testUUIDMeaningfulPkSelectViaRelationship(UUIDTest.java:107)

      The reason is that expected ObjectId of the target entity contains a value of type String instead of UUID, so expected and fetched ObjectId do not match, and Cayenne thinks there's no object for relationship.

      Attachments

        1. 0001X-testing-custom-types-as-PK.patch
          11 kB
          Andrus Adamchik
        2. 0001-testing-custom-types-as-PK.patch
          10 kB
          Andrus Adamchik

        Issue Links

          Activity

            People

              andrus Andrus Adamchik
              andrus Andrus Adamchik
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: