-->
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 and many to many
PostPosted: Fri Feb 06, 2004 10:26 am 
Newbie

Joined: Fri Feb 06, 2004 10:16 am
Posts: 7
Hello,

I'm using xdoclet to generate my hibernate mapping files but I have a problem when I'm trying to generate a many to many relationship. I have two tables which have a many to many relationship. They are linked to eachother with a third table which also contains some extra properties except the keys of the others. I have three separate classes and I'm using a many-to-one relationship in the linking table to the other two and from the two I'm using a one-to-many relationship. When I try to generate the mapping files I get an exception which says that my linking table is missing an id.

What I understand is that I haven't got it right in the xdoclet tags but I don't know how to fix it. Does anyone have any suggestions or does this question belong in the xdoclet forum?

Thanks in advance.

/K


Top
 Profile  
 
 Post subject: You must define an ID
PostPosted: Fri Feb 06, 2004 12:08 pm 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
Hi!

From what I understand of your post you want to link class A and B in a many-to-many-relationship via a class C that could be considered an entity?

Then the C-class can have an id property (it stand as optional in the Hib Docs), preferably of a Serializable and nullable type, for example java.lang.Long. I recommend you use it, it has some advantages. (see p. 20-21 in the docs)

Then you map this via XDoclet with something like this

Code:
    /**
     *
     * @hibernate.id generator-class="native" unsaved-value="null"
     */


I've also had this urge for an ID from XDoclet numerous times, so I'm a bit confused about the 'optional'-part of the ID.... but.... all you have to do is comply ;-)

Sincerely,

/F


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.