Hello,
I am very new to NHibernate, searched around the formus but couldn't get any information regarding this. I know I am missing something but can't figure it out..
Hibernate version: 2.2
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MATSORMapping" namespace="MATSORMapping">
<class name="CementType" table="CementType">
<id name="CementTypeId" column="CementTypeId">
<generator class="assigned"></generator>
</id>
<property name="CementTypeDesc" column="CementType"/>
<property name="CementTypeDetailedDesc" column="CementTypeDescription"/>
<property name="RecordStatusId" column="record_status_id"/>
</class>
</hibernate-mapping>
entity(?) class
namespace MATSORMapping
{
public class CementType
{
private int cementTypeId;
private string cementTypeDesc;
private string cementTypeDetailedDesc;
private int recordStatusId;
public virtual int CementTypeId
{
get { return cementTypeId; }
set { cementTypeId = value; }
}
public virtual string CementTypeDesc
{
get { return cementTypeDesc; }
set { cementTypeDesc = value; }
}
public virtual string CementTypeDetailedDesc
{
get { return cementTypeDetailedDesc; }
set { cementTypeDetailedDesc = value; }
}
public virtual int RecordStatusId
{
get { return recordStatusId; }
set { recordStatusId = value; }
}
}
}
Code between sessionFactory.openSession() and session.close():
void LoadData()
{
ISession session = null;
ITransaction tx =null;
try
{
session = NHibernateHelper.GetCurrentSession();
tx = session.BeginTransaction();
string sql = @"from MATSORMapping.CementType";
IQuery query = session.CreateQuery(sql);
GridView1.DataSource = query.Enumerable();
GridView1.DataBind();
tx.Commit();
}
catch (Exception ex)
{
Response.Write(ex.Message);
Response.Write(System.Environment.NewLine);
Response.Write(ex.StackTrace);
tx.Rollback();
}
finally
{
session.Close();
}
}
Full stack trace of any exception that occurs:
undefined alias or unknown mapping: MATSORMapping [from MATSORMapping.CementType] at NHibernate.Hql.Classic.PathExpressionParser.Token(String token, QueryTranslator q) at NHibernate.Hql.Classic.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q) at NHibernate.Hql.Classic.FromParser.Token(String token, QueryTranslator q) at NHibernate.Hql.Classic.ClauseParser.Token(String token, QueryTranslator q) at NHibernate.Hql.Classic.PreprocessingParser.End(QueryTranslator q) at NHibernate.Hql.Classic.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q) at NHibernate.Hql.Classic.QueryTranslator.Compile() at NHibernate.Hql.Classic.QueryTranslator.Compile(IDictionary replacements, Boolean scalar) at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow, IDictionary enabledFilters) at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar) at NHibernate.Impl.SessionImpl.Enumerable(String query, QueryParameters parameters) at NHibernate.Impl.QueryImpl.Enumerable() at MATSORMapping.AddEditCementType.LoadData() in C:\net\WebApps\vs2008\MATSORMapping\MATSORMapping\AddEditCementType.aspx.cs:line 59
Name and version of the database you are using:
SQL Server 2000
Appreciate any help with this.
|