Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Bug in DDL generation for Oracle
Bug in DDL generation for Oracle [message #520633] Sat, 13 March 2010 09:04 Go to next message
Andrew Hume is currently offline 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
Re: Bug in DDL generation for Oracle [message #522430 is a reply to message #520633] Mon, 22 March 2010 11:43 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.



James : Wiki : Book : Blog : Twitter
Previous Topic:Private Ownership and Unique Constraints
Next Topic:Fetch Join Problem
Goto Forum:
  


Current Time: Fri Aug 01 10:02:52 EDT 2014

Powered by FUDForum. Page generated in 0.01537 seconds