-->
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.  [ 1 post ] 
Author Message
 Post subject: @CollectionOfElements generates foreign key constraint
PostPosted: Mon Sep 15, 2008 1:35 pm 
Newbie

Joined: Thu Jan 22, 2004 5:07 am
Posts: 9
CollectionOfElements annotations seems to generate an incorrect foreign key constraint with hbm2ddl.


Hibernate version:
3.2.5.ga

Mapping documents:
public class SpaceObject extends BaseObject implements Serializable,
SpaceObjectI {
...

@CollectionOfElements(targetElement=Integer.class)
@JoinTable(
name="spaceObject_tag",
joinColumns = @JoinColumn(name="space_object")
)
@Column(name="uses", nullable=false)
@MapKeyManyToMany(targetEntity = Tag.class, joinColumns = @JoinColumn(name="tag_id"))
public Map<TagI, Integer> getTags() {
if (tags == null)
tags = new HashMap<TagI, Integer>();
return tags;
}
}


The generated SQL (show_sql=true):
Here's what


sweeti_test=> \d tbl_space_object__tag
Table "public.tbl_space_object__tag"
Column | Type | Modifiers
---------------+---------+-----------
space__object | bigint | not null
uses | integer | not null
tag__id | bigint | not null
Indexes:
"tbl_space_object__tag_pkey" PRIMARY KEY, btree (space__object, tag__id)
Foreign-key constraints:
"fk10c39fe12f27b5ad" FOREIGN KEY (tag__id) REFERENCES tbl_space_object(id) D
EFERRABLE
"fk10c39fe18bad9de4" FOREIGN KEY (uses) REFERENCES tbl_space_object(id) DEFE
RRABLE
"fk10c39fe1dfcf8a88" FOREIGN KEY (space__object) REFERENCES tbl_space_object
(id) DEFERRABLE


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

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.