-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: undefined alias or unknown mapping
PostPosted: Wed Apr 30, 2008 11:27 am 
Newbie

Joined: Wed Apr 30, 2008 10:54 am
Posts: 2
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.


Top
 Profile  
 
 Post subject: Re: undefined alias or unknown mapping
PostPosted: Wed Apr 30, 2008 11:55 am 
Newbie

Joined: Wed Apr 30, 2008 10:54 am
Posts: 2
please ignore my earlier post.

I forgot to mention <mapping resource=""> in the web.config. should have understood the error message... thought there was something wrong with the mapping file ... and ignored to look into web.config.

my bad! appologies!

Thanks,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.