Bug in DDL generation for Oracle [message #520633] |
Sat, 13 March 2010 09:04  |
Eclipse User |
|
|
|
If a column is marked as unique (@Column(unique=true,...)) then the DDL generated for the primary key column is UNIQUE NOT NULL. The inclusion of UNIQUE causes Oracle to complain with ORA-02261: such unique or primary key already exists in the table.
Removing unique=true from the @Column avoids the problem, but is this the correct answer? When EclipseLink reverse engineers a database table it assigns unique=true to primary key columns.
Suggest that the DDL generation code should not emit UNIQUE for Oracle.
Thoughts?
@Entity
@Table(name="ACCOUNT")
public class Account implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name="ACCOUNT_ACCOUNTID_GENERATOR", sequenceName="SEQ_ACCOUNT_ID")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ACCOUNT_ACCOUNTID_GENERATOR")
@Column(unique=true, nullable=false, precision=22)
private long accountid;
produces
CREATE TABLE ACCOUNT (ACCOUNTID NUMBER(22) UNIQUE NOT NULL, ...., PRIMARY KEY (ACCOUNTID))
Andrew
|
|
|
Re: Bug in DDL generation for Oracle [message #522430 is a reply to message #520633] |
Mon, 22 March 2010 11:43  |
Eclipse User |
|
|
|
If you set unique to true, then it sounds like we should be generating UNIQUE in the DDL, otherwise, you can set it to false.
What do you mean by "When EclipseLink reverse engineers a database table"?
Are you referring to Eclipse Dali?
You could log a bug to have unique be ignored for the pk for Oracle, I'm not sure how other databases handle this.
|
|
|
Powered by
FUDForum. Page generated in 0.04303 seconds