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