You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Jakob Braeuchi <jb...@gmx.ch> on 2004/07/01 19:14:52 UTC

Re: criteria.addEqualTo("date", date);

hi jamo,

the comparison is done in sql not in java.

jakob

Jamo Smith wrote:

> Hey Folks!
> I ran into a problem tonight trying to return a list of entries that match a 
> specific date.
> 
> For testing purposes I am passing a date object into addEqualTo that I built 
> like this:
> Date date = new Date();
> date.setTime(
> entry.getDate().getTime() (;
> 
> the entry is a entry I got by querying for all entries in the database.  
> However when I do a query like this:
> 
>         Transaction tx = implementation.newTransaction();
>         tx.begin();
>         PersistenceBroker broker = ((HasBroker) tx).getBroker();
>         Criteria criteria = new Criteria();
>         criteria.addEqualTo("date", date);
>         QueryByCriteria query = new QueryByCriteria(Entry.class, criteria);
> 
>         return broker.getCollectionByQuery(query);
> 
> according to the Date object's javadocs it uses getTime() to compare the two 
> dates.  I tested date.equals(entry.getDate()) and it returns true for at least 
> one entry in the database.  The collection is sized 0 every time.  I can't 
> figure this out for the life of me.
> 
> Thanks folks, I appreciate your support.
> - Jamo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org