-->
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.  [ 2 posts ] 
Author Message
 Post subject: XDoclet - How to set sql types for association table in *-*
PostPosted: Fri Jun 25, 2004 2:21 pm 
Regular
Regular

Joined: Wed Nov 05, 2003 10:57 pm
Posts: 96
I am using Hibernate 2.1.4 with XDoclet 1.2.1.

I have a unidirectional many-to-many association A * -------> * B

A and B have primary keys of type String (char(32)).

I want to generate the association table with the 2 foreign keys if type char(32).

This XDoclet tags:
* @hibernate.set
* role="bs"
* table="A_B_LNK"
* lazy="true"
* cascade="save-update"
* @hibernate.collection-key
* column="A_ID"
* @hibernate.collection-many-to-many
* column="B_ID"
* class="mypackage.B"

generates the following assication table:

create table A_B_LNK (
A_ID VARCHAR(255) not null, -- needed char(32)
B_ID VARCHAR(255) not null, -- needed char(32)
primary key (A_ID, A_ID)
);

I tried to use the "@hibernate.column" but id did not work with "hibernate.collection-key" or "hibernate.collection-many-to-many"

Any suggestion.

Thank you


Top
 Profile  
 
 Post subject: Same with bidirectional relation...
PostPosted: Mon Jul 05, 2004 10:21 am 
Newbie

Joined: Mon Jul 05, 2004 10:08 am
Posts: 1
Location: Amsterdam
Hello,

I have got the same problem with a bidirectional many-to-many relation. My xdoclet-code in the first class is:

/**
* @hibernate.set
* role = "dogs"
* table = "cat_dog"
*
* @hibernate.collection-many-to-many
* class = "pieterse.hibernate.persist.Dog"
* column = "dog_id"
*
* @hibernate.collection-key
* column = "cat_id"
*
* @return
*/

and in the second class...

/**
* @hibernate.set
* role = "cats"
* table = "cat_dog"
*
* @hibernate.collection-many-to-many
* class = "pieterse.hibernate.persist.Cat"
* column = "cat_id"
*
* @hibernate.collection-key
* column = "dog_id"
*
* @return
*/

The SchemaExport-tool tries to create the link table cat_dog but doesn't because of the 2 x 255 as PK restriction within MySQL.
How can we force the type and length in the code?
THNX


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.