I’m trying to introduce NHibernate to a mid-sized investment bank in NYC. It seems like a nice product and I like using xml files and entities. I figured to start using only Native SQL for the first project so they don’t have a HQL learning curve. Thus far I’m filling entities, updating the db, and such.
Am I correct that non-managed entities are ones that have no persistance? Ie: you just get an plain Ilist that is not connected, linked or related to anything or any other actions. Is there another recommended way to get this type of unconnected list/whatever?
Also
I’m getting this exception on the following code:
{"Return types of SQL query were not specified [SELECT Fund_Name, Currency FROM fund]"}
Code:
IQuery sqlQuery = session.CreateSQLQuery("SELECT Fund_Name, Currency FROM fund") .SetResultTransformer(Transformers.AliasToBean(typeof(Fund)));
IList funds = sqlQuery.List();
What is causing this error. How do I specify a return type of SQL query?
Here is the mapping and type:
Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Test.Accounting.CashTransaction.Core.Domain.Fund, CashTransaction" table="fund">
<composite-id>
<key-property name="ManagementCode" column="Management_Code" type="String" length="2" />
<key-property name="FundCode" column="Fund_Code" type="String" length ="6"/>
</composite-id>
<property name="FundName" column="Fund_Name" type="String" length="50" />
<property name="Currency" type="String" length="3"/>
</class>
</hibernate-mapping>
using System;
using System.Collections.Generic;
using System.Text;
namespace Test.Accounting.CashTransaction.Core.Domain
{
/// <summary>
/// Fund object for NHibernate mapped table 'Fund'.
/// </summary>
[Serializable]
public class Fund
{
protected string _managementCode;
protected string _fundCode;
private string _fundName;
private string _currency;
public Fund()
{
}
public virtual string ManagementCode
{
get { return _managementCode; }
set
{
_managementCode = value;
}
}
public virtual string FundCode
{
get { return _fundCode; }
set
{
_fundCode = value;
}
}
public virtual string FundName
{
get { return _fundName; }
set
{
_fundName = value;
}
}
public virtual string Currency
{
get { return _currency; }
set
{
_currency = value;
}
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}
[/code]