Bob MacCallum wrote:
> Hi all,
> 
> The following works as expected:
> 
>               ItemQuery<ArrayDesign> affyQuery = ArrayDesign.getQuery();
>               affyQuery.include(Include.SHARED);
>               affyQuery.restrict(
>                       Restrictions.eq(Hql.property("affyChip"),
>                       Expressions.integer(1)
>                               )
>                       );

I think this may depend on the database that is used. I am sure it works 
for MySQL since it uses a "bit"-column which can be either 0 or 1. I 
don't know how Postgres handles it or if maybe Hibernate is smart enough 
to fix any potential problems. I remember that our predefined queries 
that filtered on boolean columns had to come in two versions, one for 
MySQL and one for Postgres (see 
http://base.thep.lu.se/browser/trunk/config/dist/mysql-queries.xml). I 
think this has been fixed in Hibernate (or maybe in MySQL) some time 
ago, since it now works with true/false values instead of 1/0.

Another possibility is to replace Expressions.integer(1) with 
Expressions.parameter("isAffy", true, Type.BOOLEAN). This should be safe 
with any database.

> but I'm a bit puzzled why there is no "Expressions.boolean(true)" in the API.

Well, a lot of things get added when they are needed. I guess the reason 
is that we have not had any explicit need to filter on a boolean value 
before.

> Not urgent!

Ok. Considering potential database issues, I think it maybe is better to 
go for the Expresssion.parameter() in any case.

/Nicklas

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
basedb-devel mailing list
basedb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/basedb-devel

Reply via email to