Table A with columns and type
   col      data_type
   name      varchar
   id        bigint
   type      int


data is loaded fine into Cache  when following mapping used for field type

<bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
        <constructor-arg>
                <util:constant static-field="java.sql.Types.INTEGER"/>
        </constructor-arg>
        <constructor-arg value="type"/>
        <constructor-arg value="java.lang.Integer"/>
        <constructor-arg value="type"/>
</bean>


<property name="fields">
        <map>
                <entry key="type" value="java.lang.Integer"/>
                <entry key="name" value="java.lang.String"/>
                <entry key="id" value="java.lang.Long"/>
        </map>
</property>

 But fails with error below if I try to use Enum 


<bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
        <constructor-arg>
                <util:constant static-field="java.sql.Types.INTEGER"/>
        </constructor-arg>
        <constructor-arg value="type"/>
        <constructor-arg value="com.......some.SomeEnum"/>
        <constructor-arg value="type"/>
</bean>

<property name="fields">
        <map>
                <entry key="type" value="com.......some.SomeEnum"/>
                <entry key="name" value="java.lang.String"/>
                <entry key="id" value="java.lang.Long"/>
        </map>
</property>

Caused by: class org.apache.ignite.binary.BinaryObjectException: Failed to
read field [name=type]
        at
org.apache.ignite.internal.binary.BinaryFieldAccessor.read(BinaryFieldAccessor.java:192)
        at
org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:875)
        ... 16 more
Caused by: java.lang.IllegalArgumentException: Can not set
com.......some.SomeEnum field com.bla.bla.A.type to java.lang.Integer
        at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
        at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
        at
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)

        
public class A implements Serializable {
    private static final long serialVersionUID = 0L;
    private final Long id;
    private int type; // CHANGE This to SomEnum for failure case
    private final String code;
    }
        
enum SomeNum {
   FIRST(1, "FIRSTENUM");
}



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to