Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Not creating the Unique constraint on the DB (postgreSQL)
Not creating the Unique constraint on the DB (postgreSQL) [message #803201] Mon, 20 February 2012 22:07 Go to next message
FiruzzZ Mising name is currently offline FiruzzZ Mising name
Messages: 19
Registered: October 2011
Junior Member
I got this annotation on my entity class and I am sure that in another version (actually 2.3.0), this worked fine

@Entity
@Table(uniqueConstraints = {
    @UniqueConstraint(columnNames = {"institucion", "sector", "codigo"})
})
public class Afiliacion implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    protected Integer id;
    @ManyToOne(optional = false)
    protected Institucion institucion;
    @ManyToOne(optional = false)
    protected Sector sector;
    @Basic(optional = false)
    @Column(nullable = false)
    protected Integer codigo;
....


is not generating the unique on the DB (PostgreSQL)

Do am I missing something?
Re: Not creating the Unique constraint on the DB (postgreSQL) [message #803781 is a reply to message #803201] Tue, 21 February 2012 15:04 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1016
Registered: July 2009
Senior Member
This should be working, but I don't see how it can over fields "institucion" and "sector" since these are relationships and the associated database fields would use the defaults.

Can you show the DDL that gets generated? This can be obtained by using the eclipselink.ddl-generation.output-mode property with a value of "sql-script" or "both" and the file specified using the "eclipselink.create-ddl-jdbc-file-name" property.

Best Regards,
Chris
Re: Not creating the Unique constraint on the DB (postgreSQL) [message #804667 is a reply to message #803781] Wed, 22 February 2012 16:47 Go to previous message
FiruzzZ Mising name is currently offline FiruzzZ Mising name
Messages: 19
Registered: October 2011
Junior Member
I got it
EclipseLink is using the default renaming fields on institucion and sector >> COLUMNS institucion_id and sector_id
so...
@Table(uniqueConstraints = {
@UniqueConstraint(columnNames = {"institucion_id", "sector_id", "codigo"})
})

Thanks...
Previous Topic:Can I create database sessions from an external file?
Next Topic:Bidirectional OneToOne Mapping Issue
Goto Forum:
  


Current Time: Mon Jul 28 12:41:52 EDT 2014

Powered by FUDForum. Page generated in 0.17330 seconds