OpenJPA
  1. OpenJPA
  2. OPENJPA-1842

CachedEntityStatistics depends on @GeneratedValue which is not supported in Oracle by default

    Details

    • Type: Test Test
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0, 2.0.1
    • Fix Version/s: 2.0.2, 2.1.0
    • Component/s: None
    • Labels:
      None

      Description

      CachedEntityStatistics depends on @GeneratedValue which is not supported in Oracle by default unless special trigger and OracleDictionary setting is implemented.

      Otherwise, the following similar exception will be observed.

      Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01400: cannot insert NULL into ("JPAUSER"."CACHEDENTITYSTATISTICS"."ID")

      {prepstmnt 406657085 INSERT INTO CachedEntityStatistics (firstName, lastName, version) VALUES (?, ?, ?) [params=?, ?, ?]}

      [code=1400, state=23000]

      SInce TestStatistics, the test case uses CachedEntityStatistics, is not testing GeneratedValue per se, will remove the annotation and implement a simple id assignment in CachedEntityStatistics class.

        Activity

        Hide
        Rick Curtis added a comment -

        Would changing the strategy to GenerationType.AUTO make the problem go away?

        Show
        Rick Curtis added a comment - Would changing the strategy to GenerationType.AUTO make the problem go away?
        Hide
        Albert Lee added a comment -

        While you are typing, it has changed to use AUTO instead and re-running the junit bucket. Thank Mike and Rick for the suggestion.

        Albert Lee.

        Show
        Albert Lee added a comment - While you are typing, it has changed to use AUTO instead and re-running the junit bucket. Thank Mike and Rick for the suggestion. Albert Lee.
        Hide
        Rick Curtis added a comment -

        I thought about this some more last night and we're not fixing the right problem here. I think the problem is that we don't have a good way to create these special Oracle triggers in our unit test bucket.? Going the route of making sure that all of our unit tests don't use GenerationType.IDENTITY is going to be error prone, and we'll be continually chasing this problem. How feasible is it to add support for GenerationType.IDENTITY?

        FYI – As of this morning I found 20 instances of "@GeneratedValue(strategy = GenerationType.IDENTITY) " in our test bucket, but I'm not sure how many of those are actually used.

        Show
        Rick Curtis added a comment - I thought about this some more last night and we're not fixing the right problem here. I think the problem is that we don't have a good way to create these special Oracle triggers in our unit test bucket.? Going the route of making sure that all of our unit tests don't use GenerationType.IDENTITY is going to be error prone, and we'll be continually chasing this problem. How feasible is it to add support for GenerationType.IDENTITY? FYI – As of this morning I found 20 instances of "@GeneratedValue(strategy = GenerationType.IDENTITY) " in our test bucket, but I'm not sure how many of those are actually used.
        Hide
        Albert Lee added a comment -

        Changing from IDENTITY to AUTO also causes some test failures running against MSSQL:

        Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Cannot insert explicit value for identity column in table 'CachedEntityStatistics' when IDENTITY_INSERT is set to OFF.

        {prepstmnt 20188152 INSERT INTO CachedEntityStatistics (id, firstName, lastName, version) VALUES (?, ?, ?, ?) [params=?, ?, ?, ?]}

        [code=544, state=S0001]

        and Sybase:

        Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Explicit value specified for identity field in table 'CachedEntityStatistics' when 'SET IDENTITY_INSERT' is OFF.

        {prepstmnt 724577072 INSERT INTO CachedEntityStatistics (id, firstName, lastName, version) VALUES (?, ?, ?, ?) [params=?, ?, ?, ?]}

        [code=584, state=ZZZZZ]

        BTW, we are not proposing changing all IDENTITY to something else. If so that leave us a hole in testing this functionality.

        Need to take a close look at what can be done here.

        Show
        Albert Lee added a comment - Changing from IDENTITY to AUTO also causes some test failures running against MSSQL: Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Cannot insert explicit value for identity column in table 'CachedEntityStatistics' when IDENTITY_INSERT is set to OFF. {prepstmnt 20188152 INSERT INTO CachedEntityStatistics (id, firstName, lastName, version) VALUES (?, ?, ?, ?) [params=?, ?, ?, ?]} [code=544, state=S0001] and Sybase: Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Explicit value specified for identity field in table 'CachedEntityStatistics' when 'SET IDENTITY_INSERT' is OFF. {prepstmnt 724577072 INSERT INTO CachedEntityStatistics (id, firstName, lastName, version) VALUES (?, ?, ?, ?) [params=?, ?, ?, ?]} [code=584, state=ZZZZZ] BTW, we are not proposing changing all IDENTITY to something else. If so that leave us a hole in testing this functionality. Need to take a close look at what can be done here.

          People

          • Assignee:
            Albert Lee
            Reporter:
            Albert Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development