Hello!

I think that VARCHAR option is only available when object is passed to
cache store in deserialized (POJO) form. If it is passed in serialized
(BinaryObject) form then it will always store ordinal.
And, for some reason, after
https://issues.apache.org/jira/browse/IGNITE-4949 for CacheJdbcPojoStore
serialized form is always used.

+ Dmitriy

Why was this change made? Is

if (fieldVal instanceof Enum) {
    Enum val = (Enum)fieldVal;

    fieldVal = NUMERIC_TYPES.contains(field.getDatabaseFieldType()) ?
val.ordinal() : val.name();
}
block from CacheAbstractJdbcStore still useful after this change?

Regards,
-- 

Ilya Kasnacheev


вт, 28 авг. 2018 г. в 11:57, michal23849 <[email protected]>:

> Hi Ilya,
>
> Thank you for your advice. It does work now when I put my class as the
> javaFieldType. However one thing still does bother me.
>
> Previously you advised that Ignite will determine itself if the enum is
> ORDINAL or a STRING and store accordingly - either Ordinal or the Name.
>
> So I have accordingly mapped 2 fields - one as Integer and one as String.
>
> <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
>   <property name="databaseFieldType" >
>           <util:constant static-field="java.sql.Types.INTEGER"/>
>   </property>
>   <property name="databaseFieldName" value="state" />
>   <property name="javaFieldType" value="com.myModel.CState" />
>   <property name="javaFieldName" value="state" />
> </bean>
>
>
> <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
>   <property name="databaseFieldType" >
>           <util:constant static-field="java.sql.Types.VARCHAR"/>
>   </property>
>   <property name="databaseFieldName" value="type" />
>   <property name="javaFieldType" value="com.myModel.CType" />
>   <property name="javaFieldName" value="type" />
> </bean>
>
> Here is my SQLServer Table:
>
> CREATE TABLE [dbo].[CCache1](
>         [ric] [varchar](255) NOT NULL,
>         [state] [int] null,
>         [type] [varchar](255) null
> )
>
> The problem is that no matter if I map the ENUM to Integer or String - it
> always stores it as Integer, even in Varchar column. Please advise.
>
> Please see the SQLServer results after storing data in Ignite:
> select top 100 ric, state, type from [CCache1]
> ric     state   type
> .CSUS0457       1       20
>
>
>
> Thanks,
> Michal
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to