You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "xiezhi (JIRA)" <ji...@apache.org> on 2012/08/31 03:16:07 UTC

[jira] [Created] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

xiezhi created OPENJPA-2255:
-------------------------------

             Summary: Couldn't load the referencedColumn definition when create the JoinTable
                 Key: OPENJPA-2255
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
             Project: OpenJPA
          Issue Type: Bug
          Components: jpa
    Affects Versions: 2.1.1
            Reporter: xiezhi
            Priority: Minor


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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee updated OPENJPA-2255:
--------------------------------

    Fix Version/s: 2.3.0
    
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Assignee: Albert Lee
>            Priority: Minor
>              Labels: documentation, patch
>             Fix For: 2.3.0
>
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee updated OPENJPA-2255:
--------------------------------

    Attachment: OPENJPA-2255.patch
    
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Priority: Minor
>              Labels: documentation, patch
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13449778#comment-13449778 ] 

Albert Lee commented on OPENJPA-2255:
-------------------------------------

I don't think the new message is in error.

What the message saying is the classField in the database has column length 255 and whereas the id field of the @OneToMany side has column length 128. This means OpenJPA recognized the length=128 set on the id field. Before the patch, join column did not pick up the id column length and defaulted to 255, therefore this message did not happened. Either the id column has to match the join column length or the join column length need to match the id length.  

This is just the reverse of the original scenario.

Albert Lee.
                
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Assignee: Albert Lee
>            Priority: Minor
>              Labels: documentation, patch
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "xiezhi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13448409#comment-13448409 ] 

xiezhi commented on OPENJPA-2255:
---------------------------------

Thanks,Albert. I got your patch, and apply it into my server (geronimo-tomcat7-javaee6-3.0.0), The warning message mentioned in the jira did disappear, but another message occurred. Same message, same problem. But the difference is the column is defined in ManyToOne annotation.

The source is below.

 @ManyToOne(optional=true, cascade={CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name="classField") private Location schoolField;

The message is below.

2012-09-05 09:19:58,293 WARN  [Schema] Existing column "classField" on table "test.classField" is incompatible with the same column in the
 given schema definition. Existing column:
Full Name: classes.classField
Type: varchar
Size: 255
Default: null
Not Null: false
Given column:
Full Name: classes.classField
Type: varchar
Size: 128
Default: null
Not Null: false
                
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Priority: Minor
>              Labels: documentation, patch
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Assigned] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee reassigned OPENJPA-2255:
-----------------------------------

    Assignee: Albert Lee
    
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Assignee: Albert Lee
>            Priority: Minor
>              Labels: documentation, patch
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13446431#comment-13446431 ] 

Albert Lee commented on OPENJPA-2255:
-------------------------------------

This problem only happens when 
* @JoinTable is specified in the entity.
* String type entity identity field
* database table is created with join column id with length other than the database specific column length.

This problem also affects the Mapping tool creating database table operation, always assume database defect VARCHAR/CHAR length define in the database dictionary.

Attached a patch for trunk. Please try if this has resolved your issue. 

For fix/commit for 2.2.x, 2.1.x and 2.0.x releases, you will need to work with IBM service channel to get this fix in these releases.

Albert Lee.

                
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Priority: Minor
>              Labels: documentation, patch
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13449132#comment-13449132 ] 

Albert Lee commented on OPENJPA-2255:
-------------------------------------

XieZhi,

Can you provide a more concrete test case and the conditions reproducing the failure?


                
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Assignee: Albert Lee
>            Priority: Minor
>              Labels: documentation, patch
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (OPENJPA-2255) Couldn't load the referencedColumn definition when create the JoinTable

Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee resolved OPENJPA-2255.
---------------------------------

    Resolution: Fixed
    
> Couldn't load the referencedColumn definition when create the JoinTable
> -----------------------------------------------------------------------
>
>                 Key: OPENJPA-2255
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2255
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.1
>            Reporter: xiezhi
>            Assignee: Albert Lee
>            Priority: Minor
>              Labels: documentation, patch
>             Fix For: 2.3.0
>
>         Attachments: OPENJPA-2255.patch
>
>
> 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 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira