OpenJPA
  1. OpenJPA
  2. OPENJPA-2255

Couldn't load the referencedColumn definition when create the JoinTable

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.3.0
    • Component/s: jpa

      Description

      The JoinColumn couldn't have the referencedColumn's definition which includes the length definition. and it's length should be assigned to the default value 255.

      @Entity
      public class Student {
      @Id @Column(name="id", length=128, nullable=false) private String id;
      @Column(name="sName", length=255) private String sName;
      @ManyToMany
      @JoinTable(
      name="student_course_map",
      joinColumns=

      {@JoinColumn(name="student_id", referencedColumnName="id", nullable=false)}

      ,
      inverseJoinColumns=

      {@JoinColumn(name="course_id", referencedColumnName="id", nullable=false)}


      )
      public Collection getCourses()

      ...
      }

      @Entity
      public class Courses

      { @Id @Column(name="id", length=128, nullable=false) private String id; @Column(name="cName", length=255) private String cName; ... }

      We can see the student id length has been defined to 128. And there is no definition length in the JoinColumn student_id. The JoinColumn should be set to the default value 255.

      The warning message will occur like this

      WARN [Schema] Existing column "student_id" on table "test.student_course_map" is incompatible with the same column in the given schema definition. Existing column:
      Full Name: student_course_map.student_id
      Type: varchar
      Size: 128
      Default: null
      Not Null: true
      Given column:
      Full Name: student_course_map.student_id
      Type: varchar
      Size: 255
      Default: null
      Not Null: true

        Activity

        xiezhi created issue -
        Albert Lee made changes -
        Field Original Value New Value
        Attachment OPENJPA-2255.patch [ 12543347 ]
        Albert Lee made changes -
        Assignee Albert Lee [ allee8285 ]
        Albert Lee made changes -
        Fix Version/s 2.3.0 [ 12319463 ]
        Albert Lee made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development