Hi Kenan!

In ignite-1.7 we introduced JdbcTypesTransformer and its default
implementation JdbcTypesDefaultTransformer.
You need to implement MyCustomTransformer extends
JdbcTypesDefaultTransformer and handle CLOB type in your code and
delegating other types to JdbcTypesDefaultTransformer.
And after that put MyCustomTransformer to all nodes classpath and set
transformer on pojo factory.

Hope this help.

On Wed, Sep 14, 2016 at 11:48 PM, Kenan Dalley <kenan.dal...@gm.com> wrote:

> I'm getting an "argument type mismatch" for my Oracle CLOB when trying to
> call "loadCache".  I ran into similar situation like this before with
> Oracle
> Timestamp when using version 1.6 of the ignite fabric and had to upgrade to
> the 1.7.0 version of the ignite fabric to fix that defect.  This looks very
> similar.  I have an Oracle CLOB column that I'm trying to load into a
> java.lang.String field and am consistently getting the error below.  It
> works if I remove the CLOB field from my JdbcType configuration, but that's
> not going to work for us because most of our tables use CLOBs.
>
> This code is just basic test code to see if the data-caching will work with
> our Oracle datastore.
>
>
> *-----------------------------
> /EXCEPTION/
> -----------------------------*
> Caused by: javax.cache.integration.CacheLoaderException: Failed to set
> property in POJO class [type=com.gm.ignite.HistoryResult, prop=results,
> col=5, dbName=RESULTS]
>         at
> org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore.buildPojoObject(
> CacheJdbcPojoStore.java:210)
>         ... 7 more
> Caused by: java.lang.IllegalArgumentException: argument type mismatch
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 62)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at
> org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore$ClassProperty.set(
> CacheJdbcPojoStore.java:397)
>         at
> org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore$
> ClassProperty.access$300(CacheJdbcPojoStore.java:339)
>         at
> org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore.buildPojoObject(
> CacheJdbcPojoStore.java:207)
>         ... 7 more
>
> *-----------------------------
> /HISTORYRESULT TABLE/
> -----------------------------*
> COLUMN_NAME, DATA_TYPE, NULLABLE
> USER_ID, VARCHAR2(20 BYTE), No
> SESSION_ID, VARCHAR2(50 BYTE), No
> SESSION_TIME, DATE, Yes
> SESSION_NAME, VARCHAR2(50 BYTE), No
> RESULTS, CLOB, Yes
> CREATED_DT, DATE, No
> CREATED_BY, VARCHAR2(20 BYTE), No
> MODIFIED_DT, DATE, No
> MODIFIED_BY, VARCHAR2(20 BYTE), No
>
> *-------------------------------
> /HISTORYRESULTKEY CLASS/
> -------------------------------*
> public class HistoryResultKey {
>     private String userId;
>     private String sessionId;
>     private String sessionName;
> ...
>
> *-----------------------------
> /HISTORYRESULT CLASS/
> -----------------------------*
> public class HistoryResult {
>     private String userId;
>     private String sessionId;
>     private Timestamp sessionTime;
>     private String sessionName;
>     private String results;
>     private Timestamp createdDate;
>     private String createdBy;
>     private Timestamp modifiedDate;
>     private String modifiedBy;
> ...
>
> *-----------------------------
> /DEMO CLASS/
> -----------------------------*
>     public static void main(String[] args) throws IgniteException {
>         System.out.println(">>> Start demo...");
>
>         // Start Ignite node.
>         try (Ignite ignite = Ignition.start("examples/
> config/example-ignite
> - client-only.xml")) {
>             CacheJdbcPojoStoreFactory<HistoryResultKey, HistoryResult>
> pojoStoreFactory = new CacheJdbcPojoStoreFactory<>();
>
>             pojoStoreFactory.setDataSourceFactory(new
> OracleDataSourceFactory2());
>
>             // Configure cache store.
>             String cacheName = "HistoryResultCache";
>             CacheConfiguration<HistoryResultKey, HistoryResult> cfg =
> HistoryResultsCacheConfig
>                     .cache(cacheName, pojoStoreFactory);
>
>             try (IgniteCache<HistoryResultKey, HistoryResult> cache =
> ignite.getOrCreateCache(cfg)) {
>
>                 // Preload cache from database.
>                 preload(cache);
> ...
>     private static void preload(IgniteCache<HistoryResultKey,
> HistoryResult>
> cache) {
>         System.out.println();
>         System.out.println(">>> Loading entries from database.");
>
>         cache.loadCache(null, HistoryResultKey.class.getName(), "SELECT *
> FROM HISTORY_RESULTS WHERE SESSION_NAME = 'name2'");
> ...
>
> *-----------------------------
> /JAVA CACHECONFIG/
> -----------------------------*
> public class HistoryResultsCacheConfig {
>     private static JdbcType jdbcTypeHistoryResults(String cacheName) {
>         JdbcType jdbcType = new JdbcType();
>
>         jdbcType.setCacheName(cacheName);
>         jdbcType.setDatabaseSchema("SCHEMA_A");
>         jdbcType.setDatabaseTable("HISTORY_RESULTS");
>         jdbcType.setKeyType("com.gm.ignite.HistoryResultKey");
>         jdbcType.setValueType("com.gm.ignite.HistoryResult");
>
>         // Key fields for HISTORY_RESULTS.
>         Collection<JdbcTypeField> keys = new ArrayList<>();
>         keys.add(new JdbcTypeField(Types.VARCHAR, "USER_ID", String.class,
> "userId"));
>         keys.add(new JdbcTypeField(Types.VARCHAR, "SESSION_ID",
> String.class, "sessionId"));
>         keys.add(new JdbcTypeField(Types.VARCHAR, "SESSION_NAME",
> String.class, "sessionName"));
>         jdbcType.setKeyFields(keys.toArray(new
> JdbcTypeField[keys.size()]));
>
>         // Value fields for MATLAB_HISTORY_RESULTS.
>         Collection<JdbcTypeField> vals = new ArrayList<>();
>         vals.add(new JdbcTypeField(Types.VARCHAR, "USER_ID", String.class,
> "userId"));
>         vals.add(new JdbcTypeField(Types.VARCHAR, "SESSION_ID",
> String.class, "sessionId"));
>         vals.add(new JdbcTypeField(Types.TIMESTAMP, "SESSION_TIME",
> Timestamp.class, "sessionTime"));
>         vals.add(new JdbcTypeField(Types.VARCHAR, "SESSION_NAME",
> String.class, "sessionName"));
>         vals.add(new JdbcTypeField(Types.CLOB, "RESULTS", String.class,
> "results"));
>         vals.add(new JdbcTypeField(Types.TIMESTAMP, "CREATED_DT",
> Timestamp.class, "createdDate"));
>         vals.add(new JdbcTypeField(Types.VARCHAR, "CREATED_BY",
> String.class, "createdBy"));
>         vals.add(new JdbcTypeField(Types.TIMESTAMP, "MODIFIED_DT",
> Timestamp.class, "modifiedDate"));
>         vals.add(new JdbcTypeField(Types.VARCHAR, "MODIFIED_BY",
> String.class, "modifiedBy"));
>         jdbcType.setValueFields(vals.toArray(new
> JdbcTypeField[vals.size()]));
>
>         return jdbcType;
>     }
>
>     private static QueryEntity queryEntityHistoryResults() {
>         QueryEntity qryEntity = new QueryEntity();
>
>         qryEntity.setKeyType("com.gm.ignite.HistoryResultKey");
>         qryEntity.setValueType("com.gm.ignite.HistoryResult");
>
>         // Query fields for HISTORY_RESULTS.
>         LinkedHashMap<String, String> fields = new LinkedHashMap<>();
>
>         fields.put("userId", "java.lang.String");
>         fields.put("sessionId", "java.lang.String");
>         fields.put("sessionTime", "java.sql.Timestamp");
>         fields.put("sessionName", "java.lang.String");
>         fields.put("results", "java.lang.String");
>         fields.put("createdDate", "java.sql.Timestamp");
>         fields.put("createdBy", "java.lang.String");
>         fields.put("modifiedDate", "java.sql.Timestamp");
>         fields.put("modifiedBy", "java.lang.String");
>
>         qryEntity.setFields(fields);
>
>         // Aliases for fields.
>         Map<String, String> aliases = new HashMap<>();
>
>         aliases.put("userId", "USER_ID");
>         aliases.put("sessionId", "SESSION_ID");
>         aliases.put("sessionTime", "SESSION_TIME");
>         aliases.put("sessionName", "SESSION_NAME");
>         aliases.put("results", "RESULTS");
>         aliases.put("createdDate", "CREATED_DT");
>         aliases.put("createdBy", "CREATED_BY");
>         aliases.put("modifiedDate", "MODIFIED_DT");
>         aliases.put("modifiedBy", "MODIFIED_BY");
>
>         qryEntity.setAliases(aliases);
>
>         // Indexes for HISTORY_RESULTS.
>         Collection<QueryIndex> idxs = new ArrayList<>();
>
>         QueryIndex idx = new QueryIndex();
>
>         idx.setName("PK_HISTORY_RESULTS_V_A_ID");
>
>         LinkedHashMap<String, Boolean> idxFlds = new LinkedHashMap<>();
>
>         idxFlds.put("userId", true);
>         idxFlds.put("sessionId", true);
>         idxFlds.put("algorithmName", true);
>
>         idx.setFields(idxFlds);
>
>         idxs.add(idx);
>
>         qryEntity.setIndexes(idxs);
>
>         return qryEntity;
>     }
>
>     public static <K, V> CacheConfiguration<K, V> cache(String cacheName,
> CacheJdbcPojoStoreFactory<K, V> storeFactory) {
>         if (storeFactory == null)
>             throw new IllegalArgumentException("Cache store factory cannot
> be null.");
>
>         CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(
> cacheName);
>
>         ccfg.setCacheStoreFactory(storeFactory);
>         ccfg.setReadThrough(true);
>         ccfg.setWriteThrough(true);
>
>         // Configure JDBC types.
>         Collection<JdbcType> jdbcTypes = new ArrayList<>();
>
>         jdbcTypes.add(jdbcTypeHistoryResults(cacheName));
>
>         storeFactory.setTypes(jdbcTypes.toArray(new
> JdbcType[jdbcTypes.size()]));
>
>         // Configure query entities.
>         Collection<QueryEntity> qryEntities = new ArrayList<>();
>
>         qryEntities.add(queryEntityHistoryResults());
>
>         ccfg.setQueryEntities(qryEntities);
>
>         return ccfg;
>     }
> }
>
> *-----------------------------------------
> /EXAMPLE-IGNITE - CLIENT-ONLY.XML/
> -----------------------------------------*
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xsi:schemaLocation="http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans.xsd";>
>
>     <import resource="example-default - client-only.xml"/>
>
>     <bean parent="ignite.cfg"/>
> </beans>
>
> *-----------------------------------------
> /EXAMPLE-DEFAULT - CLIENT-ONLY.XML/
> -----------------------------------------*
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xmlns:util="http://www.springframework.org/schema/util";
>        xsi:schemaLocation="
>         http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans.xsd
>         http://www.springframework.org/schema/util
>         http://www.springframework.org/schema/util/spring-util.xsd";>
>
>
>     <bean id="h2-example-db" class="org.h2.jdbcx.JdbcDataSource">
>         <property name="URL" value="jdbc:h2:tcp://localhost/mem:ExampleDb"
> />
>         <property name="user" value="sa" />
>     </bean>
>
>     <bean abstract="true" id="ignite.cfg"
> class="org.apache.ignite.configuration.IgniteConfiguration">
>                 <property name="clientMode" value="true" />
>
>
>         <property name="peerClassLoadingEnabled" value="true"/>
>
>
>         <property name="includeEventTypes">
>             <list>
>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_
> TASK_SESSION_ATTR_SET"/>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
>
>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
>                 <util:constant
> static-field="org.apache.ignite.events.EventType.EVT_
> CACHE_OBJECT_REMOVED"/>
>             </list>
>         </property>
>
>
>         <property name="discoverySpi">
>             <bean
> class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
>                 <property name="ipFinder">
>
>
>
>                     <bean
> class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.
> TcpDiscoveryMulticastIpFinder">
>                         <property name="addresses">
>                             <list>
>
>                                 <value>127.0.0.1:47500..47509</value>
>                             </list>
>                         </property>
>                     </bean>
>                 </property>
>             </bean>
>         </property>
>     </bean>
> </beans>
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Argument-Type-Mismatch-for-Oracle-CLOB-tp7748.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>



-- 
Alexey Kuznetsov
GridGain Systems
www.gridgain.com

Reply via email to