McQuak
12-27-2006, 10:45 PM
Hi all.
I'm using the <loader query-ref ... /> feature of NHibernate 1.2 for define custom SQL statement for entity loading.
But it seems that this doesn't work under Spring.Data.NHibernate12.
I have following hmb.xml (for test purposes)
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Domain" namespace="Domain.Domain">
<class name="Product" table="Products">
<id name="ProductID" column="ProductID" type="System.Int32">
<generator class="hilo"/>
</id>
<property name="UnitPrice" column="UnitPrice" type="System.Decimal"/>
<property name="ProductName" column="ProductName" type="System.String" />
<loader query-ref="loadProducts"/>
</class>
<sql-query name="loadProducts">
<return alias="prod" class="Product" />
<![CDATA[
select
ProductID as {prod.ProductID},
UnitPrice as {prod.UnitPrice},
ProductName as {pod.ProductName}
from Products prod
order by ProductID desc
]]>
</sql-query>
</hibernate-mapping>
I have Dao class:
public class ProductDao : HibernateDaoSupport
{
public IList<Product> GetAll()
{
return this.HibernateTemplate.LoadAll<Product>();
}
}
But the returning IList of products is orderd by ProductID but not descending.
Even, when I make mistake in sql for loading, no error happend.
Is the custom loader usable under the Spring.Data.NHibernate12?
Thanks Tom.
I'm using the <loader query-ref ... /> feature of NHibernate 1.2 for define custom SQL statement for entity loading.
But it seems that this doesn't work under Spring.Data.NHibernate12.
I have following hmb.xml (for test purposes)
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Domain" namespace="Domain.Domain">
<class name="Product" table="Products">
<id name="ProductID" column="ProductID" type="System.Int32">
<generator class="hilo"/>
</id>
<property name="UnitPrice" column="UnitPrice" type="System.Decimal"/>
<property name="ProductName" column="ProductName" type="System.String" />
<loader query-ref="loadProducts"/>
</class>
<sql-query name="loadProducts">
<return alias="prod" class="Product" />
<![CDATA[
select
ProductID as {prod.ProductID},
UnitPrice as {prod.UnitPrice},
ProductName as {pod.ProductName}
from Products prod
order by ProductID desc
]]>
</sql-query>
</hibernate-mapping>
I have Dao class:
public class ProductDao : HibernateDaoSupport
{
public IList<Product> GetAll()
{
return this.HibernateTemplate.LoadAll<Product>();
}
}
But the returning IList of products is orderd by ProductID but not descending.
Even, when I make mistake in sql for loading, no error happend.
Is the custom loader usable under the Spring.Data.NHibernate12?
Thanks Tom.