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

JdbcPkGenerator.longPkFromDatabase would throw an exception if the PK value exceeds a range of Java int

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1B1, 3.2.M1
    • 3.1B2, 3.2.M1
    • None
    • None

    Description

      Don't have a unit test to prove it yet, so this is just based on the code review of JdbcPkGenerator and its inner class PkRetrieveProcessor:

      protected long longPkFromDatabase(DataNode node, DbEntity entity) throws Exception

      { ... PkRetrieveProcessor observer = new PkRetrieveProcessor(entity.getName()); node.performQueries(queries, observer); return observer.getId(); }

      final class PkRetrieveProcessor implements OperationObserver {

      Number id;
      ....

      public int getId() {
      if (id == null)

      { throw new CayenneRuntimeException("No key was retrieved for entity " + entityName); }

      return id.intValue();
      }

      This only affects those few DBs that do not override 'longPkFromDatabase' (H2 and HSQLDB?)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: