Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Legacy database ddl generation with duplicate column definition.


If you look at the statement, the two strings are different: "FcorpID" which is defined in the relationship is not the same case as "FcorpId" that is defined in ExcercisePK. EclipseLink is case sensitive and so adds them as different fields, where as your database is not and so throws the exception. Making them match will resolve your problem.

Best Regards,

yenan zhou wrote:
ExercisePK is as simple:


public class ExercisePK implements Serializable {
    @Basic(optional = false)
    @Column(name = "FinfoID")
    private String exerciseID;
    @Basic(optional = false)
    @Column(name = "FcorpId")
    private String corpID;

    public ExercisePK() {

    public ExercisePK(String exerciseID, String corpID) {
        this.exerciseID = exerciseID;
        this.corpID = corpID;

  ........ getters/setters/hash/equals....


In the logging I see following line:

Internal Exception: java.sql.SQLException: Column already exists:
FCORPID in statement [CREATE TABLE MB_TMBGymInfo (FleaveDt
VARCHAR(255), Fremark VARCHAR(255), FCardID VARCHAR(255), FState
VARCHAR(255), FCardCorpID VARCHAR(255), FDoPlace VARCHAR(255), FComeDt
TIMESTAMP, FtypeName VARCHAR(255), Fkind VARCHAR(255), FRoomName
VARCHAR(255), FCardCorpName VARCHAR(255), FMemberName VARCHAR(255),
FMemberID VARCHAR(255), FinfoID VARCHAR(255) NOT NULL, FcorpId
Error Code: -27

While the line is a bit long, you'll see there're two FcorpId column
definition at the end of the create statement.

I think this is due to there's one def in ExercisePK and one in
@ManyToOne mapping in Exercise. So at the creation statge, both defs
generate a column definition in sql create statement. While if I set
insertable=true in @ManyToOne mapping, I'll also see two defs in sql
update statement too, and it leads to similar error but for updates.

For reads, it's not a problem as both defs will get there needed value
'coz I think select does not prevent duplicate projection attributes.

2010/2/24 Christopher Delahunt <christopher.delahunt@xxxxxxxxxx>:

Seems odd.  Can you provide the ExercisePK class and the DDL statement that gives the problem (or the exception stack if it doesn't generate one)?

Best Regards,

----- Original Message -----
From: his.stone@xxxxxxxxx
To: eclipselink-users@xxxxxxxxxxx
Sent: Wednesday, February 24, 2010 2:00:38 AM GMT -05:00 US/Canada Eastern
Subject: Re: [eclipselink-users] Legacy database ddl generation with duplicate column definition.

Well, you do have quick eyes. However, this is not the problem. This legacy
database use "FcorpID" in exercise table and use "FCoprID" in member table.
The design is such, hence the difference in mapping column names. It's not
the error.

I searched hibernate forum for similar questions, it seemed that hibernate
has this issue too. I don't know if it's solved yet though.

If I leave insertable and updatble to default, I can even not able to update
table data since there're duplicate mappings. As I turn off these settings,
updaing is working fine, but there lacks a way to notify also schema
creation that only one mapping of the two is needed.

christopher delahunt wrote:

EclipseLink is case sensitive when it comes to processing column names,
but most databases are not.  If you have "FcorpID" in the join column as
the foreign key but "FCorpID" in the ExcercisePK mapping EclipseLink
will treat them as two separate fields instead of the same field.  This
could be why you are getting the exception on DDL generation, as
EclipseLink will try to create both fields separately.  Solution is to
make the field names the same in all definitions.

Best Regards,

zaya wrote:
It seems to be a bug of eclipselink. I'm working on a legacy database.
mapping of table is like:

... table definition

    protected ExercisePK key;

... many other columns


  @JoinColumn(name="FcorpID", referencedColumnName="FCorpID",
insertable=false, updatable=false)
    private AppMember appMember;


The problem here is that the composite primary key is composed of the
auto id and also the "FcorpID" column. Because FcorpID is a global
identifier which exits in every table to distingush similar data from

The mapping itself works fine. But when I want to test database using in
memory db and generate ddl, eclipselink throw exception that it said the
column definition "FcorpID" is duplicated and table is not created.

I'm wondering if this is a bug or there's some configuration I can use to
let eclipselink know that only one column here is needed like when
persisting I turn off insertable and updatable to disable the second
column's modification. Or is this a missing feature?

eclipselink-users mailing list

View this message in context:
Sent from the EclipseLink - Users mailing list archive at

eclipselink-users mailing list
eclipselink-users mailing list

eclipselink-users mailing list

Back to the top