1 Reply Latest reply: Jun 11, 2012 8:39 AM by cdelahun RSS

    NullPointerException with Toplink version 9.0.4.4

    107340
      Dear All,

      We are using Toplink version 9.0.4.4 jar for one of our live application.
      Ours is a Java application connected to Oracle DB with the above mentioned toplink jar in the application server.
      Currently we are facing the following issue.

      java.lang.NullPointerException
      at oracle.toplink.mappings.DirectToFieldMapping.compareObjects(DirectToFieldMapping.java:154)
      at oracle.toplink.mappings.DirectToFieldMapping.compareForChange(DirectToFieldMapping.java:136)

      We are not facing this issue on all scenarios. But unable to figure our when this issue is triggered.
      From one of the forum we saw that version 9.0.4.5 might solve this issue.
      We tried replacing the jar but the result is not fruitful. We still have the issue.

      On higher end this is how our Objects are mapped.

      Database Side
      ==============

      Employee - Primary Table
      Employee Details - Secondary table with relation to Employee table.
                One to many relation with Employee

      Java Side
      ===========
      Employee.java
      EmployeeDetails.java

      Employee.java contains list of Employee Details.

      Process Flow
      ==============
      1. Read the Employee details from the Database. Employee Object is populated and the same is used to Display the details
      in the application screen
      2. User modified the Emplohyee details in the Screen
      3. Build EmployeeAmendDTO from Employee Object along with the modified data from Screen using HTTPRequest object
      4. Read the Employee Object again from the DB and register it for Update.
      5. Logic has been written in Java to check EmployeeAmendDTO against Employee Object and populate Employee Object with
      additional information from the EmployeeAmendDTO.
      6. In this process the EmployeeDetails List within the Employee Object is also set.

           Code snippet from Employee Object
           
           EmployeeDetailsList.add(EmployeeDetails);
           EmployeeDetails.setEmployee(this);
      7. Employee Object which is registed for update should update the records.

      The code works very fine while we comment the EmployeeDetailsList.add(EmployeeDetails); code in java.
      But this is very much required as we need to save the Employee Details as well.


      Below is the relationship maintained for Employee and EmployeeDetails in Toplink.

      In Employee the EmployeeDetails are set in one-to-many relations where Bidirectional Relationship is enabled. In the EmployeeDetails bidirectional relationship is not enabled for EmployeeHolder which is holder for the Employeeobject.

      Note:- The application is in use since 2005 and we have just modified few code here and there to include new parametes to
      the Employee and EmployeeDetails.
        • 1. Re: NullPointerException with Toplink version 9.0.4.4
          cdelahun
          Hello,

          9.0.4.x is rather old and I'd recommend trying a later version such as 10 or 11 if possible. I'd also recommend filing a support case as they will probably need to go through the old and new mappings and the details of how you are building Employee and EmployeeDetails objects from EmployeeAmendDTO, which would be difficult to look at through a forum post.

          What will be needed is the full stack, the portion of the log that shows the app first reading in Employee and then trying to commit the changes with logging on finest (if possible). The error hopefully shows the mapings involved in the problem that may issolate which objects will need to be looked at.

          Best Regards,
          Chris