Hello!

>                                         <entry key="type"
value="java.lang.String" />

Why do you specify type of 'type' as String? Have you tried specifying
actual enum type here? Do you have a reproducer project of this behavior,
with e.g. H2 used as underlying database?

Regards,
-- 
Ilya Kasnacheev


ср, 23 янв. 2019 г. в 11:40, michal23849 <[email protected]>:

> Hi,
>
> I have a problem with very simple class being exposed to SQL with Enum
> field
> and want to use it togheter with custom CacheStore class managing the
> writeBehind to SQLServer database.
>
> My class is:
>
> public class Entitlement  {
>         Type type;
>         String name;
> (...)
> }
>
> Where type is an Enum:
>
> public enum Type {
>         FUNCTION,
>         INDEX
> }
>
> And I am exposing this through the Queryentities configuration where the
> enum is exposed as String:
>                     <property name="queryEntities">
>                         <list>
>                             <bean
> class="org.apache.ignite.cache.QueryEntity"  lazy-init="true">
>                                 <property name="tableName"
> value="Entitlements"/>
>                                 <property name="keyType"
> value="java.lang.String" />
>                                 <property name="valueType"
> value="com.csg.ps.d1idxrds.entitlements.model.Entitlement"/>
>                                                                 <property
> name="keyFieldName" value="name"/>
>                                 <property name="fields">
>                                     <map>
>                                         <entry key="name"
> value="java.lang.String" />
>                                         <entry key="type"
> value="java.lang.String" />
>                                     </map>
>                                 </property>
>                                 <property name="indexes">
>                                     <list>
>                                         <bean
> class="org.apache.ignite.cache.QueryIndex">
>                                             <constructor-arg>
>                                                 <list>
>                                                     <value>name</value>
>                                                 </list>
>                                             </constructor-arg>
>                                             <constructor-arg value="SORTED"
> />
>                                         </bean>
>                                     </list>
>                                 </property>
>                             </bean>
>                         </list>
>                     </property>
>
> The selects work, then I am running the following insert from SQL client
> (DBeaver):
> INSERT  INTO gen.ENTITLEMENTS(NAME, TYPE) VALUES ('PROF12', 'FUNCTION1');
>
> The cache has the native persistence turned off. The insert succeeds when
> there is no 3rd party persistence turned on.
>
> Even the following query succeeds with no cachestore (where FUNCTION1 is
> not
> in enum values):
> INSERT  INTO gen.ENTITLEMENTS(NAME, TYPE) VALUES ('PROF12', 'FUNCTION1');
>
> However when I switch on the third party persistence than the insert will
> fail complaining about the field being Enum not String.
>
> 2019-01-23T09:24:48,588 ERROR o.a.i.i.p.o.j.JdbcRequestHandler
> [client-connector-#43] Failed to execute SQL query [reqId=0,
> req=JdbcQueryExecuteRequest [schemaName=PUBLIC, pageSize=1024, maxRows=0,
> sqlQry=INSERT INTO GEN.Entitlements  (NAME, TYPE) VALUES
> ('ent1','FUNCTION'), args=[], stmtType=ANY_STATEMENT_TYPE]]
> org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to
> execute DML statement [stmt=INSERT INTO GEN.Entitlements  (NAME, TYPE)
> VALUES ('ent1','FUNCTION'), params=null]
>
> Caused by: org.apache.ignite.binary.BinaryObjectException: Failed to
> deserialize object [typeName=com.myproject.model.Entitlement]
>
> Caused by: org.apache.ignite.binary.BinaryObjectException: Failed to read
> field [name=type]
>
> Caused by: org.apache.ignite.binary.BinaryObjectException: Unexpected field
> type [pos=24, expected=Enum, actual=String]
>
> How can this be solved that the inserts using Enums are being fine by the
> CacheStore class and written to SQL DB?
>
> If i have the class witn no Enums - the inserts are working just fine and
> data are persisted in 3rd party SQLServer DB with my custom cachestore
> class' write methods.
>
> Thanks
> Michal
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to