Edit: I made a stupid typo so please ignore this thread! Thanks
Hello,
I could use a little help with a named query I'm having trouble with. The objects involved are defined as follows:
Code:
<class name="List" table="list">
<id name="id" type="long" column="id" unsaved-value="0">
<generator class="increment" />
</id>
<many-to-one name="a" class="ListItem" column="a_id" />
<many-to-one name="b" class="ListItem" column="b_id" />
</class>
<class name="ListItem" table="list_item">
<id name="id" type="long" column="id" unsaved-value="0">
<generator class="increment" />
</id>
<property name="refId" type="string" column="ref_id" not-null="true" />
</class>
I'd like to count the List objects who's a's id = "some value" OR who's b's id = "some value". So if either a's id or b's id matches the id passed in as a parameter, I want the List to be returned (or actually the count of the List to be returned).
I have the following named query:
Code:
<query name="List.countListItemsWithId">
<![CDATA[select count(x) from List as x where x.a.id=:listItemId or x.b.id=:listItemId]]>
</query>
But I'm getting the following error:
ERROR [SessionFactoryImpl] Error in named query: List.countListItemsWithId
org.hibernate.QueryException: could not resolve property: listItemId of: ListItem
Anybody have an idea how to solve that? I know that listItemId is not a property of ListItem, but listItemId is just the named parameter - not sure why named parameters must match propery names???
Many thanks![/b]