-->
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: @OneToMany mapping to a Map question
PostPosted: Tue Mar 15, 2011 11:00 am 
Newbie

Joined: Sun Aug 28, 2005 1:29 pm
Posts: 12
I have three tables:

Code:
item (id serial, ...)
item_title (id serial, item_id integer, title_id integer, active boolean, usage_start date, usage_end date)
title (id serial, line_num integer, title_type char(1), language char(2), title varchar(128))


In the Item class, I want to have a Map mapping from <line_num, title_type, language> -> item_title for active titles.

First, I created an embedded class called TitleClassifier to store the three pieces of title information: line_num, title type and language and use this in the Title class. Next, in the Item class, I define this field:

Code:
@OneToMany(mappedBy = "item")
@Where(clause = "active = 'true'")
private Map<TitleClassifier, ItemTitle> activeTitles;


When I test this, I get an exception because the generated query is looking in the item_title table for the line_num, title_type and language columns, which are in the title table, not the item_title table. I think this is happening because the Map "value" is of type ItemTitle and Hibernate is expecting the key values to come from this table as well.

Can I make this mapping this work or is it just too complicated?

Thanks
Andrew


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.