Hibernate version: 1.2.0 GA
Name and version of the database you are using: SQL 2000
Mapping documents:
<class name="UserProfile" table="user_profile">
...
<bag name="CurrentProducts" table="Products" inverse="true" cascade="all-delete-orphan" order-by="expiryDate, productDefinitionId ASC">
<key column="memberId" />
<one-to-many class="common.Product, common" />
</bag>
</class>
I have a child collection of Products. Suppose I don't usually need to load all the products, but I often need to load a particular one (the one that expires next). Is there a way to do this using NHibernate with a formula property? I tried to do it using the following mapping:
<property name="TestProduct" type="au.com.venturelogic.linkme.common.Product, common"
formula="SELECT TOP 1 * FROM Product p WHERE p.memberId = id ORDER BY p.expiryDate" />
However, NHibernate doesn't seem to accept a mapped class as a property type.
|