[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Converters, non-standard datatypes, and nulls
|
Setting the sqlType in your converter would be correct.
If the JDBC type cannot be determined from the bind value or mapping, then
VARCHAR is used as a best guess default, as this seems to work best with
most database platforms. Using Types.NULL does not seem to work with most
database platforms. If it works with PostgreSQL, you could add this check
in the PostgreSQLPlatform getJDBCType method.
Mike Traum-2 wrote:
>
> Hi,
> I've been working with a user on an active thread about writing a
> converter for a spatial datatype under postgres/postgis. This brought up
> an issue I've had in the past. It seems that when you're dealing with
> non-standard types (not a normal sql type), everything is generally
> fine. But, there always seems to be a problem when trying to store a
> null value for that type - postgres throws an exception about the column
> being of type varchar instead of the actual type.
>
> I did a little debugging, and it seems the DatabaseField.sqlType is not
> being set. If I add the code below to the converter (sets the sqlType
> to java.sql.Types.OTHER), it seems to always work. Should this be a fix
> in eclipselink (or, even better, set the type to java.sql.Types.NULL
> when the value is null)?
>
> public void initialize(DatabaseMapping dm, Session session) {
> dm.getField().setSqlType(java.sql.Types.OTHER);
> }
>
> Thanks,
> Mike
>
-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://old.nabble.com/Converters%2C-non-standard-datatypes%2C-and-nulls-tp27066937p27129557.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.