-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How to get Primary or Unique key on Associated Table?
PostPosted: Sun May 29, 2005 11:45 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:46 pm
Posts: 45
Location: Saskatoon SK Canada
Hibernate version: Hibernate 3.0.5, Hibernate Annotations Beta 2

Mapping documents:
@ManyToMany(targetEntity="x.y.z.entity.EntityType", cascade={CascadeType.PERSIST, CascadeType.MERGE})
@AssociationTable(table=@Table(name="ENTITY_TYPE_ADDRESS_TYPES",
uniqueConstraints={@UniqueConstraint(columnNames={"ADDRESS_TYPE_ID",
"ENTITY_TYPE_ID"},
primary=true)}),
joinColumns = {@JoinColumn(name="ADDRESS_TYPE_ID", nullable=false, unique=false)},
inverseJoinColumns = @JoinColumn(name="ENTITY_TYPE_ID", nullable=false, unique=false))

Debug level Hibernate log excerpt:
[DEBUG,SchemaExport,main] create table ENTITY_TYPE_ADDRESS_TYPES (
ADDRESS_TYPE_ID bigint not null,
ENTITY_TYPE_ID bigint not null
)
[DEBUG,SchemaExport,main] alter table ENTITY_TYPE_ADDRESS_TYPES
add constraint FK4410DC56C6953F
foreign key (ADDRESS_TYPE_ID)
references ADDRESS_TYPES
[DEBUG,SchemaExport,main] alter table ENTITY_TYPE_ADDRESS_TYPES
add constraint FK4410DC54E5D7242
foreign key (ENTITY_TYPE_ID)
references ENTITY_TYPES


I have defined a uni-directional many-to-many relationship using an association table. The table is created properly, but I don't seem to be able to find a way to specify that the association table should have a primary (or unique) key. I have tried adding several forms of the 'uniqueConstraints' tag (the latest is shown above) to the AssociationTable, but it is always ignored. I've tried it with a couple of different databases (HSQL and Derby), and it does the same thing in both.

Would someone point me in the right direction, please?


Thanks... Maury.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 11:41 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Add a feature request in JIRA (HibernateExt/annotations)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:58 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 2:46 pm
Posts: 45
Location: Saskatoon SK Canada
emmanuel wrote:
Add a feature request in JIRA (HibernateExt/annotations)


Done. It is EJB-5.

_________________
Maury


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.