I'm quite new to Hibernate, and in case this question had been posted many times before, I'm sorry for that. I have the following situation:
Table A (Product) ----------------- - Id (PK) - related fields
Table B (Product description) ---------------------------- - Id (FK) - Language - Description
* There's a composite PK in table B (combination of Id and Language column)
Now, I would like to write a query that returns products - including the description - but only in the language that was passed as a parameter. I tried many things, but I always get a list with all languages, so the parameter has no influence on the result. I can understand why this is the case, but however, I would like to get only the descriptions I need. Is there a way to do this via Hibernate, and if this is possible, what do I have to do then?
I haven't tested it, but it might also fill the Collection with all Languages.
Joined: Aug 02, 2007
Thanks for your answer. The solution you proposed is one of the things I tried before, and this still returns a list with all descriptions (having the same foreign key value, of course), instead of a filtered list.
The `where b.language = "language"` condition should work in Iibernate. It's one of the basic things in any query language. Maybe there's something in the mappings or code. Can you paste the ".hbm.xml" files and the part of the code where you do the query?
Joined: Aug 02, 2007
Ik work with annotations coming from the persistence 1.0 API instead of the hibernate .hbm.xml file. So my problem could be caused to a wrong implementation of those annotations. The queries are written via Hibernate API.
I'm gonna show you the mapping code I used:
Entity Product --------------
Entity Description ------------------
I changed the query a bit because it's a little bit more complicated.
when I loop through my returned product list, the descriptions map still contains all descriptions per productId. I would like to have only the descriptions in the specified language.
Carl [ July 09, 2008: Message edited by: Carl Wauters ]