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

2018-03-14 Thread ASF subversion and git services (JIRA)

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

ASF subversion and git services commented on GEODE-4693:


Commit f7c745130ba8e53a60a8cc21fd6173dbbc015f85 in geode's branch 
refs/heads/develop from [~dschneider]
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=f7c7451 ]

GEODE-4693: fix JDBCLoader on non-object pdx fields (#1517)

If the region mapping has a pdxClassName then the JdbcLoader will look for a 
pdx type that is already defined and use its field types when creating the 
PdxInstance. If the pdx type does not have a field that corresponds to an 
existing column then an exception is thrown.

A pdx field of type "char" or an instance of "java.lang.Character" will be sent 
to SQL as a String of size 1.
A pdx field of type "Date" will be sent to SQL as a java.sql.Timestamp.

A new external API was added to GemFireCache. It is the method 
"registerPdxMetaData".
It only needs to be called on clients if they are going to do reads using a 
JdbcLoader of data that wa s not written using the JdbcWriter or 
JdbcAsyncWriter.

> 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: 50m
>  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)


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

2018-03-08 Thread Anilkumar Gingade (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-4693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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)