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

Db-generated PK type mismatch

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.0M1
    • Core Library
    • None
    • MySQL 5, 3.1 and 5.0 drivers

    Description

      java class of a DB-generated PK turns out to be undefined and generally not matching the type of column it is used for. E.g. for a JDBC int column, the default Java mapping is java.lang.Integer. When a generated key is configured for this column all db's return different values:

      MySQL 5/Connector J 3.1.13 BigInteger
      MySQL 5/Connector J 5.0.6 Long
      Derby 10.2 BigDecimal

      To be fair JDBC spec does not specify what should be returned, so the vendors are doing what they want.

      This causes a number of problems in Cayenne. One specific exception - although we've hacked ObjectId comparison algorithm to unwrap the numbers and compare their numeric values, IncrementalFaultList compares DataRows and fails to match Objects against the id datarows:

      /-- Encapsulated exception ------------\
      org.apache.cayenne.CayenneRuntimeException: [v.3.0-SNAPSHOT Jun 28 2007 08:48:22] Can't find id for

      {<ObjectId:BlaBla, ID=85>; committed; [...]}

      at org.apache.cayenne.access.IncrementalFaultList$IncrementalListHelper.updateWithResolvedObjectInRange(IncrementalFaultList.java:779)
      at org.apache.cayenne.access.IncrementalFaultList.resolveInterval(IncrementalFaultList.java:427)
      at org.apache.cayenne.access.IncrementalFaultList.get(IncrementalFaultList.java:613)

      I think we need to explicitly pass the Java type we expect for the ID inside the BatchAction

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment