Imagine, you use the DummyCalendar in Calendar2DateFieldConversion.
javaToSql will be ok.
(... if (source instanceof Calendar) ...)
but sqlToJava will materialize not the DummyCalendar (that you need),
but a GregorianCalendar.
(... GregorianCalendar cal = new GregorianCalendar()...)
public cla
> Imagine, you use the DummyCalendar in Calendar2DateFieldConversion.
>
> javaToSql will be ok.
> (... if (source instanceof Calendar) ...)
>
> but sqlToJava will materialize not the DummyCalendar (that you need),
> but a GregorianCalendar.
> (... GregorianCalendar cal = new GregorianCalenda
Thanks for a suggestion!
There is a nice article, where (in the second part) the result of
improper instanceof check in inheritance hierarchy is demonstrated.
http://www.javaworld.com/javaworld/jw-01-1999/jw-01-object.html
David
Jakob Braeuchi wrote:
hi david,
the instanceof is some kind of stand
Thanks for your testcase.
Imagine, you use the DummyCalendar in Calendar2DateFieldConversion.
javaToSql will be ok.
(... if (source instanceof Calendar) ...)
but sqlToJava will materialize not the DummyCalendar (that you need),
but a GregorianCalendar.
(... GregorianCalendar cal = new GregorianC
hi david,
the instanceof is some kind of standard implemenation for equals(). see
Effective Java by Josh Bloch.
jakob
David Zejda schrieb:
I think, it would be better to use something like
((source != null) && (source.getClass()==Calendar.class))
{
...
in conversion strategies than
if (source
> > Just for curiosity what is the purpose of you own calendar class ?
>
> from Calendar apidoc:
> Subclasses of Calendar interpret a Date according to the rules of a
> specific calendar system. The platform provides one concrete
> subclass of
> Calendar: GregorianCalendar. Future subclasses c
...
David
Guillaume
-Message d'origine-
De : David Zejda [mailto:[EMAIL PROTECTED]
Envoye : samedi 24 juillet 2004 07:59
A : OJB Users List
Objet : little suggestion about "instanceof"
I think, it would be better to use something like
((source != null) && (source.getClass
4 juillet 2004 07:59
> A : OJB Users List
> Objet : little suggestion about "instanceof"
>
>
> I think, it would be better to use something like
>
> ((source != null) && (source.getClass()==Calendar.class))
> {
> ...
>
>
I think, it would be better to use something like
((source != null) && (source.getClass()==Calendar.class))
{
...
in conversion strategies than
if (source instanceof Calendar)
{
...
to avoid reducing e.g. custom Calendar subclass to Calendar during
conversion.
David
--