-->
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: Example.ExcludeProperty working inconsistently 1.2 GA
PostPosted: Wed May 16, 2007 5:46 pm 
Newbie

Joined: Wed May 16, 2007 3:52 pm
Posts: 2
Hi All

The Example.Exclude property is unable to exclude all the properties from the search and has the effect of returning all rows from the table. See code snippet below. If I comment the For loop, then I can return the appropriate row(s) from the database

Thanks
-RV
Code snippet

public List<T> GetByExample(T exampleInstance, params string[] propertiesToExclude) {
ICriteria criteria = NHibernateSession.CreateCriteria(persitentType);
Example example = Example.Create(exampleInstance);

////////////Problem lines start
foreach (string propertyToExclude in propertiesToExclude)
{
example.ExcludeProperty(propertyToExclude);
}
//////////Problem lines end

criteria.Add(example);
return criteria.List<T>() as List<T>;
}





Mapping file
<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
<class name="CompanyName.Project.AssemblyName.Domain.FQLocalClass, CompanyName.Project.AssemblyName" table="FQLocal" lazy="true">
<id name="ID" type="System.Int32" column="FQLocal_ID_D" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="TagName" type="System.String" column="FQLocal_TAGNAME" not-null="true" length="100" />

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 17, 2007 1:40 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Sorry, not sure what you are trying to achieve here. If you exclude all the properties, you are effectively removing any restrictions on the rows, so you get all the rows, sounds logical to me.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 1:03 pm 
Newbie

Joined: Wed May 16, 2007 3:52 pm
Posts: 2
Sergey, thanks for your response.

In my test scenario, I have unique value for both ID and TagName.
eg.

1, 'FirstTag'
2, 'SecondTag'
3, 'ThirdTag'
4, 'FourthTag'

And I have populated an example to search for using (1, 'FirstTag').
When I try to invoke GetByExample in the sample code without excluding any properties, I get the proper row count (1). When I try to exclude a property (either ID or TagName), I get back all 4 rows!


The Where statement is effectively doing Where (1=1)

THanks
-RV


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 1:39 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Ok if this is indeed as you describe, please submit this as a bug, including a simple test case.


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.