Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1857

Wrong exception is thrown when JoinColumn annotation is not incorrectly specified

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.0
    • 2.1.0
    • jdbc
    • None

    Description

      Consider the following scenario. Note that the referencedColumnName in Dependent5a.java does not exist in the target table. Currently OpenJPA throws PersistenceException. The correct exception should be ArgumentException indicating that "org.apache.openjpa.persistence.enhance.identity.Dependent5a.emp" defines a target of "xFIRSTNAME" for column "FIRSTNAME", but that target does not exist in table "Employee5".

      @Entity
      @IdClass(DependentId5.class)
      public class Dependent5a implements Serializable {

      private static final long serialVersionUID = 1L;
      @Id
      String name;

      @Id
      @JoinColumns(

      { @JoinColumn(name="FIRSTNAME", referencedColumnName="xFIRSTNAME"), @JoinColumn(name="LASTNAME", referencedColumnName="yLASTNAME") }

      )
      @ManyToOne
      Employee5 emp;
      ...
      }

      @Entity
      public class Employee5 implements Serializable {

      private static final long serialVersionUID = 1L;

      @EmbeddedId
      EmployeeId5 empId;
      ...
      }

      @Embeddable
      public class EmployeeId5 implements java.io.Serializable {

      String firstName;
      String lastName;
      ...
      }

      Attachments

        Activity

          People

            faywang Fay Wang
            faywang Fay Wang
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: