As it often happens, while trying to provide a concise test program that
demonstrates the problem with as few lines of code as possible, we happened
to find the heart of the problem.

The intern doing the project with the problems was using JBoss on NT and
using the Hypersonic database.  I was trying to replicate the problem using
JBoss on Solaris with Sybase.  Interestingly enough, it was this that
brought the problem to the foreground.

At the heart of the problem is the primary key that we were using for one of
our entity beans.  It was a composite key encapsulating a date and an
integer.  The hash value for the key was created by assembling a string of
the two values and taking a hash off that.  If I was thinking more clearly,
I would have noticed the problem earlier as the debugging was printing out
different formatted strings for the same object (java.util.Date).

When trying to replicate the problem on Solaris and Sybase, I came across
the problem of now jaws mapping for a java.util.Date.  After looking into
the standardjaws.xml file, I decided that a java.sql.Date would have to do.
However my application seemed to be working exactly as intended.

The next step was to execute it on the NT box with Hypersonic.  Another
problem.  Jaws doesn't have any mapping for java.sql.Date to the Hypersonic
database.  A quick edit of standardjaws.xml and a restart of JBoss and that
problem is fixed.  Everything seemed to be working on the NT system now.
However the intern's project was still exhibiting strange behaviour.  It was
then that the relevance of the debugging format made itself clear.

All of the debugging was using the objects toString method.  Sometimes the
debugging for the java.util.Date would show the time (all as zeros) which is
the toString for the java.util.Date, and sometimes it would just show the
date, which is the implementation of the java.sql.Date.  

What appeared to be happening was the java.util.Date was actually a
java.sql.Date under the covers.  And this somehow was screwing up our
equality tests.  By changing the underlying field in the bean and the
primary key to a java.sql.Date instead of a java.util.Date everything then
worked.

Black magic (ooh aaah).

Tim Penhey


------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated 
recipient(s) named above.  If you are not the intended recipient of this message you 
are hereby notified that any review, dissemination, distribution or copying of this 
message is strictly prohibited.  This communication is for information purposes only 
and should not be regarded as an offer to sell or as a solicitation of an offer to buy 
any financial product, an official confirmation of any transaction, or as an official 
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or 
error-free.  Therefore, we do not represent that this information is complete or 
accurate and it should not be relied upon as such.  All information is subject to 
change without notice.



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to