Good suggestion. I checked the database and it's in datetime format. It's storing the time too because the time shows up properly when I do entries, and it also gets retrieved properly if I retrieve an single entry to match a timestamp.


I even checked the hbm.xml file - timestamp as well. Any other possibilities?

-tim


On Friday, January 17, 2003, at 06:44 PM, Ken Robinson wrote:


The first thought that comes to mind is that your database column is not
storing
time information, i.e. year/month/day only. You might want to take a look
at that.


-----Original Message-----
From: Timothy Kettering [mailto:[EMAIL PROTECTED]
Sent: Friday, January 17, 2003 4:35 PM
To: [EMAIL PROTECTED]
Subject: [Hibernate] problems with date comparision


I'm using Hibernate with a program that I'm developing, and one my small test units turned up a weird issue that I'm not sure if is a bug or i'm screwing up somewhere...

This is the query I have:

                        be = sess.find("select entry from entry in class " +
                                "com.blackcore.blogserver.general.BlogEntry
where entry.timestamp >
? " +
                                "and entry.blog.id = ?" +
                                " order by entry.timestamp asc limit ?",
params, types);

 From what I figure, this should return all entry objects with a
timestamp (actually an date object) greater than the supplied date
parameter.

But what happened at first was that it returned (first in the List) the
entry with the matching timestamp supplied, rather than the next one
with a greater timestamp.  In the process of trying to figure out what
went on, I manually increased the Date object by 100,000 milliseconds
to see if I could get it to skip the first object returned.  No such
luck.  Still returned the first object with the matching timestamp.
Heres an output of the debug strings I put in, it outputs the timestamp
of the parameter before and after incrementing it.  And you can see
from the output below that it STILL returns #227, in spite of the fact
that it's less than the post-modification timestamp!

before the modification: 1042042968000
  after the modification: 1042052968000
Id is: 227 // first object returned - this shouldnt be returned.
Time is: 1042042968000
Id is: 228 // second object returned .. this should be the first!
Time is: 1042519996000

If i set it to try to try to retrieve the next X entry objects after
the most recent entry object in the database, (without advancing the
timestamp parameter), it returns only last entry object.  But if I do
the timestamp advance before passing in the parameter, it returns
nothing, which is the right behavior.

The strange thing is that I have a method with is exactly the same as
this, but returns a List of entry objects that are LESS than the
timestamp.  and it works just as expected, no problems with that.  Its
just weird.  Anyone have any insights?  I'm using hibernate 1.2.2 with
a mysql database.

-tim



-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
allow you to extend the highest allowed 128 bit encryption to all your
clients even if they use browsers that are limited to 40 bit encryption.
Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel



-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
allow you to extend the highest allowed 128 bit encryption to all your
clients even if they use browsers that are limited to 40 bit encryption.
Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel





-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
allow you to extend the highest allowed 128 bit encryption to all your clients even if they use browsers that are limited to 40 bit encryption. Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




Reply via email to