-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with Criteria
PostPosted: Wed Oct 10, 2007 6:19 am 
Newbie

Joined: Sun Aug 19, 2007 7:44 am
Posts: 9
Hi all,

i need help with the following problem. I have a class "BaseRating" and a Class "Rating" which inherits from "BaseRating".
If i want to get only a BaseRating with criteria then there occurs a error saying that a property (Mandator) can not be found in "Rating"
This is curios, cause this class is not involved in this task.

Mapping:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Helaba.Hera.Common.BLL.Entities" assembly="Helaba.Hera.Common.BLL.Entities">
<class name="BaseRating" table="Rating" lazy="false">
<id name="ID">
<column name="RatingID" sql-type="int32" not-null="true"/>
<generator class="identity" />
</id>

<property name="BorrowerName" column="BorrowerName"/>
<property name="BorrowerNr" column="BorrowerNr"/>
<property name="TransactionName" column="[Transaction]"/>

<property name="_moduleID" column="ModuleID" access="field"/>
<many-to-one name="Mandator" class="Helaba.Hera.Common.BLL.Entities.Mandator, Helaba.Hera.Common.BLL.Entities" column="MandatorID" cascade="none" lazy="false"/>

</class>
</hibernate-mapping>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Helaba.Hera.LoanReceivables.BLL.Entities" assembly="Helaba.Hera.LoanReceivables.BLL.Entities">

<joined-subclass name="Helaba.Hera.LoanReceivables.BLL.Entities.Rating" table="lrmRating" extends="Helaba.Hera.Common.BLL.Entities.BaseRating, Helaba.Hera.Common.BLL.Entities" lazy="false">
<key column="RatingID"/>
</joined-subclass>
</hibernate-mapping>

Classes:
Code:
public class BaseRating : BaseEntity
    {
        private String _borrowerName;
        private String _borrowerNr;
        private String _trans;
        private Mandator _mandator;
        protected int _moduleID;

        public String BorrowerName {
            get { return _borrowerName; }
            set { _borrowerName = value; }
        }

        public String BorrowerNr {
            get { return _borrowerNr; }
            set { _borrowerNr = value; }
        }

        public String TransactionName {
            get { return _trans; }
            set { _trans = value; }
        }

        public Mandator Mandator {
            get { return _mandator; }
            set { _mandator = value; }
        }
}

public class Rating : BaseRating
    {
        public Rating():base() {
           
        }
}

Criteria/Getting the records:
Code:
session = NHibernateSessionHelper.GetCurrentSession();

ICriteria crit = session.CreateCriteria(typeof(BaseRating),"br");

crit.Add(Expression.Eq("br.Mandator.ID",1));
crit.Add(Expression.Eq("_moduleID", 2));

IList<BaseRating> res = crit.List<BaseRating>();


So at this point there occurs an error saying:
NHibernate.QueryException was caught
Message="could not resolve property: Mandator of: Helaba.Hera.LoanReceivables.BLL.Entities.Rating"
Source="NHibernate"
StackTrace:
bei NHibernate.Persister.Entity.AbstractPropertyMapping.ThrowPropertyException(String propertyName)
bei NHibernate.Persister.Entity.AbstractPropertyMapping.ToType(String propertyName)
bei NHibernate.Persister.Entity.AbstractEntityPersister.GetSubclassPropertyTableNumber(String propertyPath)
bei NHibernate.Persister.Entity.AbstractEntityPersister.ToColumns(String alias, String propertyName)
bei NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumns(String propertyName, ICriteria subcriteria)
bei NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetColumnsUsingProjection(ICriteria subcriteria, String propertyName)
bei NHibernate.Expression.SimpleExpression.ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary enabledFilters)
bei NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition(IDictionary enabledFilters)
bei NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor(IOuterJoinLoadable persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor factory, CriteriaImpl criteria, Type rootEntityName, IDictionary enabledFilters)
bei NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, Type rootEntityName, IDictionary enabledFilters)
bei NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
bei NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria)
bei NHibernate.Impl.CriteriaImpl.List[T]()
bei Helaba.Hera.Common.DAL.BaseRatingDataManager.GetRatingsByCriteriaInternal(List`1 critExpressions, Mandator mandator) in C:\Dokumente und Einstellungen\HTE1890\Eigene Dateien\Visual Studio 2005\Projects\Hera\Helaba.Hera.Common.DAL\BaseRatingDataManager.cs:Zeile 260.


So anyone an idea???? Why is Rating in play?

Hope you can help me
Greetz
Mike


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

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.