Bernt M. Johnsen wrote On 03/01/06 11:21,: >>>>>>>>>>>>>Craig L Russell wrote (2006-03-01 10:02:58): >> >>I have to say I don't understand the rationale for throwing an >>exception here. Looking at the stack trace, I agree with Bernt that >>the user is calling setObject(column, null). What I don't agree with >>is that there is any ambiguity as to what the user means. >> >>The setObject javadoc sez: >> >>The JDBC specification specifies a standard mapping from Java Object >>types to SQL types. The given argument will be converted to the >>corresponding SQL type before being sent to the database....This >>method throws an exception if there is an ambiguity, for example, if >>the object is of a class implementing more than one of the interfaces >>named above. > > > I actually agree with Craig that there is no ambiguity "as to what the > user means" (at least if the null was intentional and not a bug). > > But formally Java "null" and SQL "NULL" is two different concepts. In > addition, the tutorial (3.0 ed.) has the same interpretation as me.
I agree that Java null and SQL NULL are different concepts. SQL doesn't have the notion of reference types versus primitive types; it just knows about values. So there are numerous places where NULL is treated very differently from non-NULL values: if you compare NULL with anything else, you get UNDEFINED; and you can treat UNDEFINED in special ways when performing joins (LEFT OUTER JOIN is different from LEFT JOIN). Java has its own quirks. Reference types are different from primitive types: you can compare reference types using identity always, but only compare reference types for equality if they are non-null; you can't compare reference types with primitive types unless you convert the reference type to a primitive. But I would say that these differences should not necessarily affect the JDBC API to the extent that this issue has exposed. The JDBC is supposed to rationalize the differences between the two worlds, and I don't see that setObject(column, null) has to work the way it does. But I also agree that the spec is loose enough that you can drive any size elephant through this tent. Craig > -- Craig Russell 408 276-5638 Architect mailto:[EMAIL PROTECTED] Sun Microsystems, Inc. http://java.sun.com/products/jdo PS: A good JDO? O gasp!
