Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate - using properties from set in subselect
    primarykey
    data
    text
    <p>I have the fallowing mapping:</p> <pre><code>&lt;class name="Country" table="Country" lazy="false" &gt; &lt;cache usage="read-write"/&gt; &lt;id name="Id" column="Id" type="Guid"&gt; &lt;generator class="assigned"/&gt; &lt;/id&gt; &lt;property name="Name" column="Name" type="String" length="50" not-null="true" unique="true" /&gt; &lt;set name="LocalizedProperties" where="LocalizedEntityClass = 'Prayon.Entities.Country'" cascade="delete"&gt; &lt;key column="EntityId" foreign-key="none" /&gt; &lt;one-to-many class="LocalizedProperty" /&gt; &lt;/set&gt; &lt;/class&gt; </code></pre> <p>LocalizedProperty is declared as follows:</p> <pre><code>&lt;class name="LocalizedProperty" table="LocalizedProperty"&gt; &lt;cache usage="read-write"/&gt; &lt;id name="Id" column="Id"&gt; &lt;generator class="guid.comb"/&gt; &lt;/id&gt; &lt;property name="CultureName" not-null="true"/&gt; &lt;property name="PropertyName" not-null="true"/&gt; &lt;property name="PropertyValue" not-null="true"/&gt; &lt;any id-type="Guid" name="Entity"&gt; &lt;column name="LocalizedEntityClass" not-null="true"/&gt; &lt;column name="EntityId" not-null="false"/&gt; &lt;/any&gt; &lt;/class&gt; </code></pre> <p>Now I try to create a select with hql which should return all Countries, with the fallowing "normal" SQL-Select</p> <pre><code>select * from Country a where ( select top 1 PropertyValue from LocalizedProperty x where x.EntityId = a.Id and x.PropertyName = 'Name' and x.LocalizedEntityClass = 'Prayon.Entities.Country' and x.CultureName = 'de') Like 'a%' </code></pre> <p>When I create the hql like </p> <pre><code>from Country a where ( select PropertyValue from LocalizedProperty x where x.EntityId = a.Id and x.PropertyName = 'Name' and x.LocalizedEntityClass = 'Prayon.Entities.Country' and x.CultureName = 'de' take 1) Like :val </code></pre> <p>and set the parameter val to a%</p> <p>I get the following <code>QueryException</code>:</p> <blockquote> <p>could not resolve property: EntityId of: Prayon.Entities.LocalizedProperty [from Country a where (select PropertyValue from LocalizedProperty x where x.EntityId = a.Id and x.PropertyName = 'Name' and x.LocalizedEntityClass = 'Prayon.Entities.Country' and x.CultureName = 'de' take 1) Like :val]</p> </blockquote> <p>I hope someone can help me how to setup my hql.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload