Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Converters, non-standard datatypes, and nulls

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



Back to the top