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: could not resolve property
PostPosted: Sat Mar 01, 2008 3:42 pm 
Beginner
Beginner

Joined: Mon Feb 04, 2008 1:48 pm
Posts: 30
I have a SiteProduct class with a Product (class) property and a Site (class) property. It is a mapping to an assosiation table for a many yo many relation between Site and Product.

I get the "could not resolve property" error for the following because it looks like the Product property is not initialised.
{CProxyTypeElementSix_Library_DomainLayerProductDomainLayer_NHibernate_ProxyINHibernateProxy1}

But this is inside a session and the object graph has been locked for the current session.

How can I do this correctly?

Code:
ICriteria criteria = Session.CreateCriteria(typeof(SiteProduct));
                    criteria.Add(Expression.Like("Product.Name", name));
                    criteria.Add(Expression.Eq("Product.Category.ID", categoryID));
                    criteria.Add(Expression.Eq("Product.IsComposite", isComposite));

                criteria.Add(Expression.Eq("IsProduced", isProduced));
                criteria.Add(Expression.IsNull("DeletedOn"));
                IList<SiteProduct> siteProducts = criteria.List<SiteProduct>();


{"could not resolve property: Product.IsComposite of: ElementSix.Library.DomainLayer.SiteProduct"}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 01, 2008 4:05 pm 
Beginner
Beginner

Joined: Mon Feb 04, 2008 1:48 pm
Posts: 30
It figures as soon as I posted this I kept looking for an answer and finally found one...

See 12.4. Associations in the documentation...

Code:
IList cats = sess.CreateCriteria(typeof(Cat))
    .Add( Expression.Like("Name", "F%")
    .CreateCriteria("Kittens")
        .Add( Expression.Like("Name", "F%") )
    .List();


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.