Thursday, July 23, 2020

Re: java.sql.Date - java.util.Date serialization issue

You could write a custom field serializer for java.sql.Date.  Serialize the information you need to recreate with the fidelity required for your use case.

On Thursday, July 23, 2020 at 10:17:25 AM UTC-4 ralph.f...@gmail.com wrote:
I know it is quite some time ago since you posted this, but I just now (2020!) ran into the very same issue (using the very same workaraound). Is there any real solution for this by now?


On Tuesday, August 22, 2006 at 2:32:24 AM UTC+2, StudyBlue wrote:
Casting 'non-serializable' objects to 'serializable' objects alone is
not enough!

1.  According to the serialization documentation for the GWT,
java.util.Date is serializable.
(
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.SerializableTypes.html
)
2.  According to the java docs, java.sql.Date is a subclass of
java.util.Date.
( http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html )
3.  According to you-can-look-it-up-yourself you can validly cast a
subclass to the type of the superclass.

Intuitively, you should be able to send java.sql.Dates across the RPC
boundary simply by casting them.  Unfortunately, the reflection calls
appear to look for the most specific type possible, not necessarily
whatever it was cast to last.  (Maybe that's intended.  Maybe I'm
totally off on my blind guess for what's causing this.)  No matter how
I cast I java.sql.Date to java.util.Date, the call would always throw
an exception claiming I was trying to send a java.sql.Date.  Eventually
I got fed up with that and created a new java.util.Date from the
java.sql.Date's getTime() method.  Creating an entirely new object
solved the problem, but I'm assuming that's taking more time and
processing than a simple cast.  If there's any way to make a sufficient
cast, I'd love to hear it.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/1d2098c9-4380-48b9-9202-86da9ccb54b4n%40googlegroups.com.

No comments:

Post a Comment