Re: Queryentities - inserts with the Enum fields - failing with cachestore turned on
Hello! It doesn't seem like SQL will support Enums now (either with SELECT or DML) regardless of Query Entities: Please watch for https://issues.apache.org/jira/browse/IGNITE-4575 Regards, -- Ilya Kasnacheev ср, 23 янв. 2019 г. в 19:43, michal23849 : > Hi, > > When i specify as: > > > Then I got the error when converting the inputs to Enum: > > 2019-01-23T17:38:48,340 ERROR o.a.i.i.p.o.j.JdbcRequestHandler > [client-connector-#79] 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: Value > conversion failed [from=java.lang.String, > to=com.myproject.model.EntitlementType] > Caused by: org.h2.message.DbException: Hexadecimal string contains non-hex > character: "FUNCTION" [90004-195] > > Unless there is another way to enforce the conversion in some more direct > way? > > Regards > Michal > > > > > -- > Sent from: http://apache-ignite-users.70518.x6.nabble.com/ >
Re: Queryentities - inserts with the Enum fields - failing with cachestore turned on
Hi, When i specify as: Then I got the error when converting the inputs to Enum: 2019-01-23T17:38:48,340 ERROR o.a.i.i.p.o.j.JdbcRequestHandler [client-connector-#79] 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: Value conversion failed [from=java.lang.String, to=com.myproject.model.EntitlementType] Caused by: org.h2.message.DbException: Hexadecimal string contains non-hex character: "FUNCTION" [90004-195] Unless there is another way to enforce the conversion in some more direct way? Regards Michal -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Queryentities - inserts with the Enum fields - failing with cachestore turned on
Hello! > 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 : > 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: > > > class="org.apache.ignite.cache.QueryEntity" lazy-init="true"> > value="Entitlements"/> > value="java.lang.String" /> > value="com.csg.ps.d1idxrds.entitlements.model.Entitlement"/> > name="keyFieldName" value="name"/> > > > value="java.lang.String" /> > value="java.lang.String" /> > > > > > class="org.apache.ignite.cache.QueryIndex"> > > > name > > > /> > > > > > > > > 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/ >
Queryentities - inserts with the Enum fields - failing with cachestore turned on
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: name 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/
Queryentities - inserts with the Enum fields - failing with cachestore turned on
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: name 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/