You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Anilkumar Gingade (JIRA)" <ji...@apache.org> on 2018/03/08 20:40:00 UTC

[jira] [Commented] (GEODE-4693) JDBCLoader on region with a pdx-class-name causes exception during deserialization when a get is done

    [ https://issues.apache.org/jira/browse/GEODE-4693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16391887#comment-16391887 ] 

Anilkumar Gingade commented on GEODE-4693:
------------------------------------------

When a get is done from JDBC:
 * if the JDBC region mapping does not have a pdx-class-name, then a PdxInstance will be created with all object fields. This PdxInstance will never deserialize to a java class but will remain a PdxInstance.
 * if the JDBC region mapping does have a pdx-class-name, then the pdx type for that class name must exist and all the columns must have corresponding fields in the pdx type. If not a JdbcConnectorException will be thrown. The pdx field type is used to determine what JDBC ResultSet method will be called to get the column data as a Java object. The following shows the ResultSet method that corresponds to the pdx field type:
 ** boolean: getBoolean
 ** byte: getByte
 ** char: getString and then the first character of the string is used
 ** short: getShort
 ** int: getInt
 ** long: getLong
 ** float: getFloat
 ** double: getDouble
 ** Date: getTimestamp
 ** String: getString
 ** byte[]: getBytes
 ** Object: getObject
 ** boolean[]: getObject
 ** char[]: getObject
 ** short[]: getObject
 ** int[]: getObject
 ** long[]: getObject
 ** float[]: getObject
 ** double[]: getObject
 ** String[]: getObject
 ** Object[]: getObject
 ** byte[][]: getObject

When a put is done to JDBC if the pdx value has a "char" field or an "Object" field that contains an instance of "Character" then the actual data written to JDBC will be an instance of "String" that is created by calling "Character.toString". In previous releases the "Character" was passed directly to JDBC setObject which results in a SQLException. So any releases with this fix can now use pdx "char" fields and "Object" fields that contain an instance of "Character".

A new external API will be added that allows a pdx type to be registered without doing a region put.

 

 

> JDBCLoader on region with a pdx-class-name causes exception during deserialization when a get is done
> -----------------------------------------------------------------------------------------------------
>
>                 Key: GEODE-4693
>                 URL: https://issues.apache.org/jira/browse/GEODE-4693
>             Project: Geode
>          Issue Type: Bug
>          Components: docs, extensions, regions
>    Affects Versions: 1.4.0
>            Reporter: Fred Krone
>            Assignee: Anilkumar Gingade
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> When Region.get() is performed with JDBCLoader and pdx-class-name, the JDBCLoader always creates a PdxInstance whose fields are all of type object. If the domain class has the fields as some other type, for example string or int, then deserialization will fail.
> Workaround at this time is:
>  # Don't set the pdx-class-name on the jdbc region mapping. This will cause deserialization to never happen since the data will remain a PdxInstance.
>  #  Have all your domain class fields serialized as pdx object fields. This can be hard to do with the ReflectionBasedAutoSerializer so the recommendation is to use PdxSerializable or your own PdxSerializer.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)