-->
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.  [ 4 posts ] 
Author Message
 Post subject: ICriteria throws NHibernate.MappingException
PostPosted: Mon Jan 28, 2008 10:49 am 
Newbie

Joined: Sun Jan 13, 2008 10:25 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 1.2.0.4000

Mapping documents: LogicalForm with Annotations no *.hbm file available

Full stack trace of any exception that occurs:
System.Web.Services.Protocols.SoapException: The request can not be handled from the server ---> NHibernate.MappingException: Property path [SkaiForms.Visual.Domain.BO.Company.Logicalform.Property3] does not reference a collection
by NHibernate.Expression.AbstractEmptinessExpression.GetQueryableCollection(Type entityType, String actualPropertyName, ISessionFactoryImplementor factory)
by NHibernate.Expression.AbstractEmptinessExpression.ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary enabledFilters)
by NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition(IDictionary enabledFilters)
by 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 SkaiForms.Visual.Data.GenericNHibernateDao`2.getByExpression(ICriterion expression, ICriterion expression2, String propertyname) in GenericNHibernateDao.cs:Line 71.
bei SkaiForms.Visual.WebService.TreeService.getPropertieTreeEntrys(String propertyFieldName, Int64 formId) in TreeService.asmx.cs:Line 118.

Name and version of the database you are using: MySQL 5


The result: I will get objects in a IList which "property3"-Field is not null and not empty.

I try to do this with the code below. But i always get an "NHibernate.MappingException". The datatype of the database field is string an is set to "NOT NULL". An empty string is possible!!

I hope you know what I mean and can help me.

Code:
ICompanyDaoFactory companyDaoFactory = new NHibernate_Company_DaoFactory();
            ILogicalformDao logicalForm = companyDaoFactory.GetLogicalFormDao();

            ICriterion exp = Expression.IsNotNull( propertyFieldName );
            AbstractEmptinessExpression exp3 = Expression.IsNotEmpty( propertyFieldName );

            IList<Logicalform> logFormList = logicalForm.getByExpression(exp, exp3, propertyFieldName );


Code:
public System.Collections.Generic.IList<T> getByExpression( ICriterion expression, ICriterion expression2, string propertyname )
        {
            ICriteria criteria = session.CreateCriteria( persitentType ).Add( expression ).Add( expression2 );  //throw NHibernate.MappingException

            return criteria.List<T>();
        }


greetz mknoppik


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 12:24 pm 
Newbie

Joined: Sun Jan 13, 2008 10:25 am
Posts: 7
[Finish]
I have a solution:
AbstractCriterion exp4 = Expression.Not( Expression.Eq( propertyFieldName, "" ) );

[Next problem]
It is possible to get only one Property in a list and not the whole object? And how can I set the result as Unique like SQL-"DISTINCT"?

greetz mknoppik


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 12:47 pm 
Regular
Regular

Joined: Wed Jun 21, 2006 3:13 pm
Posts: 110
I think you might be better off with an hql or sql query if you only want a single property back and not the entire object. The documentation sheds some more light on this but let me know if you need an example.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 1:02 pm 
Newbie

Joined: Sun Jan 13, 2008 10:25 am
Posts: 7
At time I try it with Example.ExcludeProperty(string param) in a foreach loop to exclude the specific properties and add the "Example" object instance to the ICriteria instance. at time it dows not work.

I will try it without SQL and HQL to use only the dynamic of objects.

sry for my bad english, I am since over 30 hours awake.

greetz mknoppik


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.