thanks Luiz,
anyway, I just discovered the root cause, in fact, Spring's hibernate
template does not support excludeProperty method.. etc.
just use hibernate's API , the following code is working fine!
== my correct code==
public List getUsers(User user) {
Example ex =
Example.create(user).excludeProperty("enabled");
results =
getSession().createCriteria(User.class).add(ex).list();
return results
}
Luiz Fernando Rodrigues-2 wrote:
>
> I believe you can use the type Boolean in your class instead of
> primitive values. This will solve the problem because you can set the
> property as null if you don't want to consider it.
>
> Luiz
>
> On 11/30/06, Man-Chi Leung <[EMAIL PROTECTED]> wrote:
>> hi,
>>
>> I am trying to use hibernate.criterion.Example to find User by Example
>>
>> this following code will only get all users which username="myuser" &
>> enabled="false"
>> NOT all user regardless enabled = true or false
>>
>> bcos when invokes 'new User("myuser")' , user.enabled will be
>> initialized by constructor as false by default.
>>
>> any solution ? pls advise!
>>
>> ===UserDao.java===
>> public List getUsers(User user) {
>> return results = getHibernateTemplate().findByExample(
>> Example.create(new
>> User("myuser")));
>> }
>>
>>
>> ===Another Try but still failed ===
>> return results = getHibernateTemplate().findByExample(
>> Example.create(new User("myuser")).excludeProperty("enabled"));
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/how-to-use-hibernate.criterion.Example-to-getUsers%28%29-regardless-of-%22enabled%22-field-tf2733872s2369.html#a7627332
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]