-->
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: Getting CategorizedItem to work ... with or without xdoclet
PostPosted: Fri Apr 28, 2006 10:12 am 
Newbie

Joined: Sat Jan 14, 2006 8:03 pm
Posts: 18
Hello.

I have been struggling with a similar situation to the Category-CategorizedItem-Item mapping in my project and having read Hibernate in Action, decided to download caveatemptor to see how they did it.

What's puzzling about the Category.hbm.xml file is they give you 2 ways to do the mapping in the 0.9.5 version and 3 in the 3.1 version.

The apparent difference between the two mappings in version 0.9.5 is, the first one does NOT allow you to have additional columns in the association table, and the second one does.

What I don't get is, apart from the fact that the first mapping uses a Set and the second a Bag, they both use an intermediate class, CategorizedItem, which has username and dateAdded columns, columns in the association table, right? So what's the difference between the two?

And with version 3.1, there are three different mappings. One seems to be just a plain-old many-to-many relationship with Items, meaning you can't have additional columns in the association table. The second one looks almost identical to the first mapping from 0.9.5 version. The only difference is version 0.9.5 has outer-join="false" and 3.1 has fetch="subselect". And the value for access is a Hibernate class, "DirectSetAccessor" for version 0.9.5, whereas it's just "field" for version 3.1.

The third mapping uses CategorizedItemComponent instead of CategorizedItem. I really don't know what the difference is, looking at the code, and CategorizedItemComponent doesn't have an .hbm.xml file.

Whew! So which one should I use? I would opt for the first mapping of version 0.9.5 (second mapping of version 3.1, more or less) if it weren't for the fact that the text in Category.hbm.xml says it can't be used if you have additional elements in the association table. I'll have to try it out, see if that's true.

And I'd use the second mapping from version 0.9.5 except that it says in the text "We use an intermediate class, CategorizedItem, that represents the link (However, it is a value type in this case, the packaged CategorizedItem class will not work!)"

... so it seems that won't work. And I'd use the third mapping from version 3.1, but I really don't know how it works!

So what's a geek to do? Anyone successfully implemented this? Xdoclet code would be much MUCH appreciated (my framework requires it), even tho I read that some people on this don't like it ...

Many thanks in advance,
Bob


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.