You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Zhi Xie <da...@gmail.com> on 2012/08/27 16:10:48 UTC
Existing column XXX on table XXXX is incompatible with the same
column in the given schema definition.
I have met a problem using openjpa2.1.1.
I have defined a JoinTable "user_group" with a JoinColumn "uName", the
uName is a column of Table user defined varchar(128). But there is not a
length attribute inJoinColumn. So the default value 255 is set on the
JoinColumn
uName.
My question is how to avoid the warning.
WARN [Schema] Existing column "uName" on table "test.user_group" is
incompatible with the same column in the given schema definition. Existing
column:
Full Name: user_group.uName
Type: varchar
Size: 128
Default: null
Not Null: true
Given column:
Full Name: user_group.uName
Type: varchar
Size: 255
Default: null
Not Null: true
I want to find a solution to avoid the warning.
Could anybody give me any comment?
--
Best Regards
Gary
Re: Existing column XXX on table XXXX is incompatible with the same
column in the given schema definition.
Posted by Bengt Rodehav <be...@rodehav.com>.
I've had a similar problem that I brought up on this mailing list:
http://osdir.com/ml/users.openjpa.apache.org/2012-03/msg00028.html
Never did get any replies if i remember correctly. Would be nice if this
was fixed since it is clearly a bug.
/Bengt
2012/8/28 gary <da...@gmail.com>
> I think it should be avoided by add some annotation, or it is my mistake.
> Otherwise, it is a bug which has been fixed or not.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Existing-column-XXX-on-table-XXXX-is-incompatible-with-the-same-column-in-the-given-schema-definitio-tp7580948p7580956.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>
Re: Existing column XXX on table XXXX is incompatible with the same
column in the given schema definition.
Posted by gary <da...@gmail.com>.
I think it should be avoided by add some annotation, or it is my mistake.
Otherwise, it is a bug which has been fixed or not.
--
View this message in context: http://openjpa.208410.n2.nabble.com/Existing-column-XXX-on-table-XXXX-is-incompatible-with-the-same-column-in-the-given-schema-definitio-tp7580948p7580956.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: Existing column XXX on table XXXX is incompatible with the same
column in the given schema definition.
Posted by Zhi Xie <da...@gmail.com>.
Do you mean
@ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(name="user_group", joinColumns=@JoinColumn(name="uName",
referencedColumnName="id", nullable=false) @Column(length=128)),
inverseJoinColumns=@JoinColumn(name="gName", referencedColumnName = "id")
@Column(length=256)) private Set<Group> groupsField;
It's not correct. Could you tell me the correct one?
2012/8/28 Albert Lee <al...@gmail.com>
> You can try annotate the length of the id column uName in the Entity with
> @Column(length=127) to match the length in the join table, assuming you can
> not change the join table's column length.
>
>
> On Mon, Aug 27, 2012 at 9:10 AM, Zhi Xie <da...@gmail.com> wrote:
>
> > I have met a problem using openjpa2.1.1.
> > I have defined a JoinTable "user_group" with a JoinColumn "uName", the
> > uName is a column of Table user defined varchar(128). But there is not a
> > length attribute inJoinColumn. So the default value 255 is set on the
> > JoinColumn
> > uName.
> >
> > My question is how to avoid the warning.
> >
> > WARN [Schema] Existing column "uName" on table "test.user_group" is
> > incompatible with the same column in the given schema definition.
> Existing
> > column:
> > Full Name: user_group.uName
> > Type: varchar
> > Size: 128
> > Default: null
> > Not Null: true
> > Given column:
> > Full Name: user_group.uName
> > Type: varchar
> > Size: 255
> > Default: null
> > Not Null: true
> >
> > I want to find a solution to avoid the warning.
> > Could anybody give me any comment?
> > --
> > Best Regards
> > Gary
> >
>
>
>
> --
> Albert Lee.
>
--
Best Regards
Gary
Re: Existing column XXX on table XXXX is incompatible with the same
column in the given schema definition.
Posted by gary <da...@gmail.com>.
I give a complete sample to explain my issue.
@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
--
View this message in context: http://openjpa.208410.n2.nabble.com/Existing-column-XXX-on-table-XXXX-is-incompatible-with-the-same-column-in-the-given-schema-definitio-tp7580948p7580955.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: Existing column XXX on table XXXX is incompatible with the same
column in the given schema definition.
Posted by Zhi Xie <da...@gmail.com>.
Sorry, I have misunderstanded. Do you mean annotate the length of the id
column? Sure, it is.
public class User implements Serializable
{
private static final long serialVersionUID = 1l;
@Id @Column(name="id", length=128, nullable=false) private String id;
But in the JoinTable definination the uName is set to the default value
255. So the warning message occurs.
You can refer the OpenJPA2.1.1
source org.apache.openjpa.jdbc.schema.SchemaTool.java
// order is important in this method; start with columns
Table[] tabs;
Table dbTable;
Column[] cols;
Column col;
DBIdentifier defaultSchemaName =
DBIdentifier.newSchema(_dict.getDefaultSchemaName());
for (int i = 0; i < schemas.length; i++) {
tabs = schemas[i].getTables();
for (int j = 0; j < tabs.length; j++) {
cols = tabs[j].getColumns();
dbTable = db.findTable(schemas[i],
tabs[j].getQualifiedPath(), defaultSchemaName);
for (int k = 0; k < cols.length; k++) {
if (dbTable != null) {
DBIdentifier colName = cols[k].getIdentifier();
col = dbTable.getColumn(colName);
if (col == null) {
if (addColumn(cols[k]))
dbTable.importColumn(cols[k]);
else
_log.warn(_loc.get("add-col", cols[k],
tabs[j]));
} else if (!cols[k].equalsColumn(col)) {
_log.warn(_loc.get("bad-col", new Object[]{
col, dbTable, col.getDescription(),
cols[k].getDescription() }));
}
}
}
}
}
2012/8/28 Albert Lee <al...@gmail.com>
> You can try annotate the length of the id column uName in the Entity with
> @Column(length=127) to match the length in the join table, assuming you can
> not change the join table's column length.
>
>
> On Mon, Aug 27, 2012 at 9:10 AM, Zhi Xie <da...@gmail.com> wrote:
>
> > I have met a problem using openjpa2.1.1.
> > I have defined a JoinTable "user_group" with a JoinColumn "uName", the
> > uName is a column of Table user defined varchar(128). But there is not a
> > length attribute inJoinColumn. So the default value 255 is set on the
> > JoinColumn
> > uName.
> >
> > My question is how to avoid the warning.
> >
> > WARN [Schema] Existing column "uName" on table "test.user_group" is
> > incompatible with the same column in the given schema definition.
> Existing
> > column:
> > Full Name: user_group.uName
> > Type: varchar
> > Size: 128
> > Default: null
> > Not Null: true
> > Given column:
> > Full Name: user_group.uName
> > Type: varchar
> > Size: 255
> > Default: null
> > Not Null: true
> >
> > I want to find a solution to avoid the warning.
> > Could anybody give me any comment?
> > --
> > Best Regards
> > Gary
> >
>
>
>
> --
> Albert Lee.
>
--
Best Regards
Gary
Re: Existing column XXX on table XXXX is incompatible with the same
column in the given schema definition.
Posted by Albert Lee <al...@gmail.com>.
You can try annotate the length of the id column uName in the Entity with
@Column(length=127) to match the length in the join table, assuming you can
not change the join table's column length.
On Mon, Aug 27, 2012 at 9:10 AM, Zhi Xie <da...@gmail.com> wrote:
> I have met a problem using openjpa2.1.1.
> I have defined a JoinTable "user_group" with a JoinColumn "uName", the
> uName is a column of Table user defined varchar(128). But there is not a
> length attribute inJoinColumn. So the default value 255 is set on the
> JoinColumn
> uName.
>
> My question is how to avoid the warning.
>
> WARN [Schema] Existing column "uName" on table "test.user_group" is
> incompatible with the same column in the given schema definition. Existing
> column:
> Full Name: user_group.uName
> Type: varchar
> Size: 128
> Default: null
> Not Null: true
> Given column:
> Full Name: user_group.uName
> Type: varchar
> Size: 255
> Default: null
> Not Null: true
>
> I want to find a solution to avoid the warning.
> Could anybody give me any comment?
> --
> Best Regards
> Gary
>
--
Albert Lee.