-->
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: DateBridge Broken
PostPosted: Fri Feb 04, 2011 4:42 pm 
Newbie

Joined: Wed Dec 03, 2003 5:58 pm
Posts: 4
Location: New York City
I have been happily using Search (3.3.0 FINAL) in a mission critical financial trading application until I noticed that date handling is broken. We use Hibernate with Oracle (ojdbc14-10.2.0.4 driver) as our persistence layer.

Some dates are loaded by Hibernate as java.sql.Timestamp instances. When these timestamp instances are processed by the out-of-the-box DateBridge bad things happen.

Anyone else experiencing this problem? The fix is to build a replacement for the out-of-the-box date bridge implementation that does not make use of the Lucene DateTools class. I have an implementation that solves this issue, gets rid of heavy synchronization that may limit performance of optimized (i.e. multi-threaded - mass indexing), and fixes another major bug (if you use Resolution.DAY then DateTools will drop the day instead of dropping the hour).

Another problem is that DateTools assumes that the dates being fed to it are in GMT. This is a huge (bad) assumption. The solution is to let user specify the desired TimeZone - using annotations of course.

I will post this to the Lucene team as well.


Top
 Profile  
 
 Post subject: Re: DateBridge Broken
PostPosted: Mon Feb 07, 2011 4:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

thanks for your feedback.
Quote:
Some dates are loaded by Hibernate as java.sql.Timestamp instances. When these timestamp instances are processed by the out-of-the-box DateBridge bad things happen.

Can you elaborate on this? What is the problem with java.sql.Timestamp?Maybe you could create an issue in http://opensource.atlassian.com/project ... se/HSEARCH including a testcase?

Quote:
Anyone else experiencing this problem? The fix is to build a replacement for the out-of-the-box date bridge implementation that does not make use of the Lucene DateTools class. I have an implementation that solves this issue, gets rid of heavy synchronization that may limit performance of optimized (i.e. multi-threaded - mass indexing), and fixes another major bug (if you use Resolution.DAY then DateTools will drop the day instead of dropping the hour).

I guess you are talking about https://issues.apache.org/jira/browse/LUCENE-1070. Your problem seems to be caused by using a non UTC time zone. If you want to stick with that, the right approach is to use a custom bridge implementation. Personally I think it makes sense to store all dates in the UTC timezone and to make sure that dates entered by users or used for searches get the same treatment. What if the timezone of your server changes?

--Hardy


Top
 Profile  
 
 Post subject: Re: DateBridge Broken
PostPosted: Mon Feb 07, 2011 11:20 am 
Newbie

Joined: Wed Dec 03, 2003 5:58 pm
Posts: 4
Location: New York City
We use Hibernate/Search in a mission critical fixed income trading application. Complete indexing is done, in a fixed timezone, at the end of each day - thus conversion of dates to-from GMT is not necessary. As you point out, the solution was a custom date bridge that allows timezone to be specified via annotations. In our patch the annotation looks like the following ('default' is the default timezone):

Code:
    @FieldBridge(impl = CSDateBridge.class, params = {
            @Parameter(name = "resolution", value = "DAY"),
            @Parameter(name = "timezone", value = "default") })



The problem with java.sql.Timestamp is that it contains nanosecond resolution and for some cases - e.g. time is set to 00:00:00 - it can cause the date to be incorrectly converted to a String.


Top
 Profile  
 
 Post subject: Re: DateBridge Broken
PostPosted: Wed Feb 09, 2011 12:26 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
From the javadocs of java.sql.Timestamp:

Quote:
Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance.


So you definitely need a custom bridge for Timestamp.


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.