Skip to main content


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 14:04 Go to next message
Andrew Hume is currently offline Andrew HumeFriend
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 15:43 Go to previous message
James Sutherland is currently offline James SutherlandFriend
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: Thu Apr 25 20:04:33 GMT 2024

Powered by FUDForum. Page generated in 0.03082 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top