1. OpenJPA
  2. OPENJPA-2120

Add new option to eliminate reflection calls from enhancer generated IdClass PC copy operations


    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.0, 2.3.0
    • Component/s: Enhance, kernel, performance
    • Labels:


      Profiling has shown the code in the enhancer generated pcCopyKeyFields(To/From)ObjectId to be costly when using id classes with an entity that uses field access and has non-public fields. Without public fields, reflection is used to move the values from the parent entity to the id class. This also involves a costly temporary access switch.

      I have a fix that interrogates the id class for a public constructor and uses that constructor (instead of costly reflection) during the copy operation. It only works for certain IdClass and entity combinations. IdClasses must have a trivial public constructor with parameters that match those of the id fields. Trivial = the constructor can only do direct field assignments from the parameter values to the id class values. No conversion can take place. The constructor can have other logic, but the assignments must be direct. The entity ids cannot be derived from other identities. If these conditions are not met, the enhancer falls back to using reflection.

      Since this change could result in an application behavior change (the provider calling a new constructor) it is gated by the openjpa.OptimizeIdCopy property, with the default being false.


        Jeremy Bauer created issue -
        Jeremy Bauer made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.2.0 [ 12315910 ]
        Resolution Fixed [ 1 ]
        Albert Lee made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Jeremy Bauer added a comment -

        Adding optimization support for methods that use a field manager

        Jeremy Bauer added a comment - Adding optimization support for methods that use a field manager
        Jeremy Bauer made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Jeremy Bauer made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s 2.3.0 [ 12319463 ]
        Resolution Fixed [ 1 ]
        Mark Struberg made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        4h 30m 1 Jeremy Bauer 07/Feb/12 01:25
        Closed Closed Reopened Reopened
        35d 5h 26m 1 Jeremy Bauer 13/Mar/12 21:22
        Reopened Reopened Resolved Resolved
        76d 19h 2m 1 Jeremy Bauer 29/May/12 17:24
        Resolved Resolved Closed Closed
        1103d 19h 24m 2 Mark Struberg 06/Jun/15 22:19


          • Assignee:
            Jeremy Bauer
            Jeremy Bauer
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Due: