Skip to main content


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] Tue, 21 February 2012 03:07 Go to next message
FiruzzZ Mising name is currently offline FiruzzZ Mising nameFriend
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 20:04 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
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 21:47 Go to previous message
FiruzzZ Mising name is currently offline FiruzzZ Mising nameFriend
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: Fri Dec 06 20:27:16 GMT 2024

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

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

Back to the top