I'm running into a really weird problem using Criteria to make a really simple query of a table, and am starting to wonder if this is a bug.
For starters, Criteria works fine without any expression. For example:
Code:
IList songList = session.CreateCriteria(typeof(SongType)).List();
...works perfectly fine. However, if I add criteria into the mix:
Code:
IList songList = session.CreateCriteria(typeof(SongType)) .Add(NHibernate.Expression.Property.ForName("Artist").Like("botti",MatchMode.Anywhere))
.List();
...I get the following exception:
Code:
Failure could not resolve property: Artist of: com.brightharbour.schema.SongProviderType
For whatever reason, NHibernate get confused when it attempts to resolve properties. Here's my mapping files:
SongTypeCode:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<class name="com.brightharbour.schema.SongType, BH.Service" table="Songs" lazy="false">
<id name="MediaKey" column="MediaKey" type="String">
<generator class="assigned" />
</id>
<property name="Title" type="String"/>
<property name="Artist" type="String"/>
<property name="Album" type="String"/>
<property name="Genre" type="String"/>
<property name="Description" type="String"/>
<property name="Duration" type="String"/>
<property name="Publisher" type="String"/>
<property name="Copyright" type="String"/>
<property name="Thumbnail" type="String"/>
<property name="Hits" type="Int32"/>
<property name="Tags" type="String"/>
</class>
</hibernate-mapping>
SongProviderTypeCode:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<class name="com.brightharbour.schema.SongProviderType, BH.Service" table="ProviderSongs" lazy="false">
<id name="MediaPrimaryKey" column="MediaPrimaryKey" type="Int32">
<generator class="identity" />
</id>
<property name="MediaKey" type="String" />
<property name="MediaId" type="String" />
<property name="MimeType" type="String"/>
<property name="SourceUrl" type="String"/>
</class>
</hibernate-mapping>