-->
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: Filtering the parent of a n-n map by data of the element
PostPosted: Wed Feb 24, 2010 2:48 pm 
Beginner
Beginner

Joined: Sat Jan 26, 2008 6:33 am
Posts: 24
Hello!

For Language-Support I use the tables Language, LanguageString and LanguageTranslation. LanguageString is containing the head records, while LanguageTranslation is a many-to-many relationship between Language and LanguageString containing the text. While Language is quite obvious, LanguageString and LanguageTranslation is mapped with the following code:
Code:
   <class name="LanguageString" table="LanguageString">
      <id name="_id" column="Id" type="int" unsaved-value="0" access="field">
         <generator class="identity" />
      </id>
      <many-to-one name="_defaultLanguage" column="DefaultLanguage" access="field" not-null="true" />
      <property name="_alias" column="Alias" type="string" length="200" access="field" />
      <property name="_type" column="Type" access="field" />

      <map name="_translations" table="LanguageTranslation" access="field" lazy="true" inverse="false" cascade="all">
         <key column="LanguageString" />
         <index-many-to-many column="Language" class="Language" />
         <element column="Text" type="string" length="4000" />
      </map>

   </class>

This results in a very lovely usage like:
Code:
string text = LanguageString.Translations[Language];

Now there is one case, where i need the LanguageStrings that contain a certain Text in the Translations collection. I now solved it with a SQL-Query like:
Code:
select distinct ls.* from LanguageString as ls inner join LanguageTranslation as lt on lt.LanguageString = ls.Id and lt.Text like :text

The question is: How do I solve this with (preferably) ICriteria or HQL without ugly subqueries?

Many Thanks!
Zorgoban


Top
 Profile  
 
 Post subject: Re: Filtering the parent of a n-n map by data of the element
PostPosted: Fri Feb 26, 2010 10:06 am 
Beginner
Beginner

Joined: Sat Jan 26, 2008 6:33 am
Posts: 24
I start to understand why people in the industry dislike open source projects. Even if the community is big, as soon as your questions need some higher knowledge its nearly impossible to get support.


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.