openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zhi Xie <daxie...@gmail.com>
Subject Re: Existing column XXX on table XXXX is incompatible with the same column in the given schema definition.
Date Tue, 28 Aug 2012 01:18:51 GMT
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 <allee8285@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 <daxiezhi@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message