| Bug in DDL generation for Oracle [message #520633] |
Sat, 13 March 2010 09:04  |
Andrew Hume Messages: 18 Registered: December 2009 |
Junior Member |
|
|
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
|
|
|