ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-2832 Implemented datasource creation via factory.
Date Wed, 27 Apr 2016 08:17:31 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2832 [created] 2fb74a987


IGNITE-2832 Implemented datasource creation via factory.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2fb74a98
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2fb74a98
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2fb74a98

Branch: refs/heads/ignite-2832
Commit: 2fb74a987e488487a4282a7de94b2d8f4e553b44
Parents: 3be3d16
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Wed Apr 27 15:17:53 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Wed Apr 27 15:17:53 2016 +0700

----------------------------------------------------------------------
 .../store/jdbc/CacheJdbcPojoStoreFactory.java   |  55 ++++--
 .../CacheJdbcPojoStoreAbstractSelfTest.java     |  45 +++--
 .../cache/store/jdbc/H2DatasourceFactory.java   |  18 ++
 .../src/test/config/jdbc-pojo-store-builtin.xml | 179 +++++++++++++++++++
 .../src/test/config/jdbc-pojo-store-obj.xml     | 179 +++++++++++++++++++
 .../store/jdbc/CachePojoStoreXmlSelfTest.java   |  34 ++++
 .../cache/store/jdbc/H2DataSourceFactory.java   |  18 ++
 7 files changed, 504 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2fb74a98/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
index ded83ce..d2d887e 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactory.java
@@ -133,6 +133,9 @@ public class CacheJdbcPojoStoreFactory<K, V> implements Factory<CacheAbstractJdb
     /** Data source. */
     private transient DataSource dataSrc;
 
+    /** Data source factory. */
+    private Factory<DataSource> dataSrcFactory;
+
     /** Application context. */
     @SpringApplicationContextResource
     private transient Object appCtx;
@@ -150,26 +153,26 @@ public class CacheJdbcPojoStoreFactory<K, V> implements Factory<CacheAbstractJdb
 
         if (dataSrc != null)
             store.setDataSource(dataSrc);
-        else {
-            if (dataSrcBean != null) {
-                if (appCtx == null)
-                    throw new IgniteException("Spring application context resource is not
injected.");
+        else if (dataSrcBean != null) {
+            if (appCtx == null)
+                throw new IgniteException("Spring application context resource is not injected.");
 
-                IgniteSpringHelper spring;
+            IgniteSpringHelper spring;
 
-                try {
-                    spring = IgniteComponentType.SPRING.create(false);
+            try {
+                spring = IgniteComponentType.SPRING.create(false);
 
-                    DataSource data = spring.loadBeanFromAppContext(appCtx, dataSrcBean);
+                DataSource data = spring.loadBeanFromAppContext(appCtx, dataSrcBean);
 
-                    store.setDataSource(data);
-                }
-                catch (Exception e) {
-                    throw new IgniteException("Failed to load bean in application context
[beanName=" + dataSrcBean +
-                        ", igniteConfig=" + appCtx + ']', e);
-                }
+                store.setDataSource(data);
+            }
+            catch (Exception e) {
+                throw new IgniteException("Failed to load bean in application context [beanName="
+ dataSrcBean +
+                    ", igniteConfig=" + appCtx + ']', e);
             }
         }
+        else if (dataSrcFactory != null)
+            store.setDataSource(dataSrcFactory.create());
 
         return store;
     }
@@ -181,6 +184,7 @@ public class CacheJdbcPojoStoreFactory<K, V> implements Factory<CacheAbstractJdb
      * @return {@code This} for chaining.
      * @see CacheJdbcPojoStore#setDataSource(DataSource)
      */
+    @Deprecated
     public CacheJdbcPojoStoreFactory<K, V> setDataSource(DataSource dataSrc) {
         this.dataSrc = dataSrc;
 
@@ -355,6 +359,29 @@ public class CacheJdbcPojoStoreFactory<K, V> implements Factory<CacheAbstractJdb
         return this;
     }
 
+    /**
+     * Gets factory for underlying datasource.
+     *
+     * @return Cache store factory.
+     */
+    @SuppressWarnings("unchecked")
+    public Factory<DataSource> getDataSourceFactory() {
+        return dataSrcFactory;
+    }
+
+    /**
+     * Sets factory for underlying datasource.
+
+     * @param dataSrcFactory Datasource factory.
+     * @return {@code this} for chaining.
+     */
+    @SuppressWarnings("unchecked")
+    public CacheJdbcPojoStoreFactory<K, V> setDataSourceFactory(Factory<DataSource>
dataSrcFactory) {
+        this.dataSrcFactory = dataSrcFactory;
+
+        return this;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(CacheJdbcPojoStoreFactory.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fb74a98/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
index a526b8c..41a6136 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
@@ -39,7 +39,6 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.h2.jdbcx.JdbcConnectionPool;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -61,6 +60,9 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
     /** Person count. */
     protected static final int PERSON_CNT = 100000;
 
+    /** Test cache name. */
+    protected static final String CACHE_NAME = "test-cache";
+
     /** Flag indicating that tests should use transactional cache. */
     protected static boolean transactional;
 
@@ -147,11 +149,12 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
         JdbcType[] storeTypes = new JdbcType[2];
 
         storeTypes[0] = new JdbcType();
+        storeTypes[0].setCacheName(CACHE_NAME);
         storeTypes[0].setDatabaseSchema("PUBLIC");
         storeTypes[0].setDatabaseTable("ORGANIZATION");
 
         if (builtinKeys) {
-            storeTypes[0].setKeyType("java.lang.Integer");
+            storeTypes[0].setKeyType("java.lang.Long");
             storeTypes[0].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Integer.class,
"id"));
         }
         else {
@@ -166,11 +169,12 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
             new JdbcTypeField(Types.VARCHAR, "CITY", String.class, "city"));
 
         storeTypes[1] = new JdbcType();
+        storeTypes[1].setCacheName(CACHE_NAME);
         storeTypes[1].setDatabaseSchema("PUBLIC");
         storeTypes[1].setDatabaseTable("PERSON");
 
         if (builtinKeys) {
-            storeTypes[1].setKeyType("java.lang.Long");
+            storeTypes[1].setKeyType("java.lang.Integer");
             storeTypes[1].setKeyFields(new JdbcTypeField(Types.INTEGER, "ID", Long.class,
"id"));
         }
         else {
@@ -195,6 +199,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
     protected CacheConfiguration cacheConfiguration() throws Exception {
         CacheConfiguration cc = defaultCacheConfiguration();
 
+        cc.setName(CACHE_NAME);
         cc.setCacheMode(PARTITIONED);
         cc.setAtomicityMode(transactional ? TRANSACTIONAL : ATOMIC);
         cc.setSwapEnabled(false);
@@ -203,7 +208,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
         CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>();
         storeFactory.setDialect(new H2Dialect());
         storeFactory.setTypes(storeTypes());
-        storeFactory.setDataSource(JdbcConnectionPool.create(DFLT_CONN_URL, "sa", "")); //
H2 DataSource
+        storeFactory.setDataSourceFactory(new H2DataSourceFactory()); // H2 DataSource factory.
 
         cc.setCacheStoreFactory(storeFactory);
         cc.setReadThrough(true);
@@ -283,7 +288,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * Check that data was loaded correctly.
      */
     protected void checkCacheContent() {
-        IgniteCache<Object, Object> c1 = grid().cache(null);
+        IgniteCache<Object, Object> c1 = grid().cache(CACHE_NAME);
 
         c1.loadCache(null);
 
@@ -332,7 +337,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
      * @throws Exception If failed.
      */
     private void checkPut() throws Exception {
-        IgniteCache<PersonKey, Person> c1 = grid().cache(null);
+        IgniteCache<Object, Person> c1 = grid().cache(CACHE_NAME);
 
         Connection conn = getConnection();
         try {
@@ -346,12 +351,14 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
 
             U.closeQuiet(rs);
 
-            // Test put-insert.
-            PersonKey key = new PersonKey(-1);
-
             Date testDate = Date.valueOf("2001-05-05");
 
-            c1.put(key, new Person(-1, -2, testDate, "Person-to-test-put-insert", 999));
+            Person val = new Person(-1, -2, testDate, "Person-to-test-put-insert", 999);
+
+            Object key = builtinKeys ? Integer.valueOf(-1) : new PersonKey(-1);
+
+            // Test put-insert.
+            c1.put(key, val);
 
             rs = stmt.executeQuery();
 
@@ -392,6 +399,15 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
     /**
      * @throws Exception If failed.
      */
+    public void testPutBuiltIn() throws Exception {
+        startTestGrid(true, false, false, false);
+
+        checkPut();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testPut() throws Exception {
         startTestGrid(false, false, false, false);
 
@@ -401,6 +417,15 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
     /**
      * @throws Exception If failed.
      */
+    public void testPutTxBuiltIn() throws Exception {
+        startTestGrid(true, false, false, true);
+
+        checkPut();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testPutTx() throws Exception {
         startTestGrid(false, false, false, true);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fb74a98/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DatasourceFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DatasourceFactory.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DatasourceFactory.java
new file mode 100644
index 0000000..d2feebb
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/H2DatasourceFactory.java
@@ -0,0 +1,18 @@
+package org.apache.ignite.cache.store.jdbc;
+
+import javax.cache.configuration.Factory;
+import javax.sql.DataSource;
+import org.h2.jdbcx.JdbcConnectionPool;
+
+/**
+ * Datasource to use for store tests.
+ */
+public class H2DataSourceFactory implements Factory<DataSource> {
+    /** DB connection URL. */
+    private static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1";
+
+    /** {@inheritDoc} */
+    @Override public DataSource create() {
+        return JdbcConnectionPool.create(DFLT_CONN_URL, "sa", "");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fb74a98/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml b/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
new file mode 100644
index 0000000..c72c26d
--- /dev/null
+++ b/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- This configuration was generated by GridGain Web Console (04/25/2016 14:59) -->
+
+<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 class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="gridName" value="test-cluster"/>
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <value>127.0.0.1:47500..47503</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="test-cache"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="readFromBackup" value="true"/>
+                    <property name="copyOnRead" value="true"/>
+
+                    <property name="cacheStoreFactory">
+                        <bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
+                            <property name="dataSourceFactory">
+                                <bean class="org.apache.ignite.cache.store.jdbc.H2DataSourceFactory"/>
+                            </property>
+
+                            <property name="dialect">
+                                <bean class="org.apache.ignite.cache.store.jdbc.dialect.H2Dialect"/>
+                            </property>
+                            <property name="types">
+                                <list>
+                                    <bean class="org.apache.ignite.cache.store.jdbc.JdbcType">
+                                        <property name="cacheName" value="test-cache"/>
+                                        <property name="keyType" value="java.lang.Long"/>
+                                        <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Organization"/>
+                                        <property name="databaseSchema" value="PUBLIC"/>
+                                        <property name="databaseTable" value="ORGANIZATION"/>
+
+                                        <property name="keyFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="id"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.INTEGER"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="id"/>
+                                                    <property name="javaFieldType" value="java.lang.Integer"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+
+                                        <property name="valueFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="name"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="name"/>
+                                                    <property name="javaFieldType" value="java.lang.String"/>
+                                                </bean>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="city"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="city"/>
+                                                    <property name="javaFieldType" value="java.lang.String"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+                                    </bean>
+
+                                    <bean class="org.apache.ignite.cache.store.jdbc.JdbcType">
+                                        <property name="cacheName" value="test-cache"/>
+                                        <property name="keyType" value="java.lang.Integer"/>
+                                        <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/>
+                                        <property name="databaseSchema" value="PUBLIC"/>
+                                        <property name="databaseTable" value="PERSON"/>
+
+                                        <property name="keyFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="id"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.INTEGER"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="id"/>
+                                                    <property name="javaFieldType" value="java.lang.Integer"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+
+                                        <property name="valueFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="name"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="name"/>
+                                                    <property name="javaFieldType" value="java.lang.String"/>
+                                                </bean>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="birthday"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.DATE"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="birthday"/>
+                                                    <property name="javaFieldType" value="java.sql.Date"/>
+                                                </bean>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="ORG_ID"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.INTEGER"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="orgId"/>
+                                                    <property name="javaFieldType" value="java.lang.Integer"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+                                    </bean>
+                                </list>
+                            </property>
+                        </bean>
+                    </property>
+
+                    <property name="readThrough" value="true"/>
+                    <property name="writeThrough" value="true"/>
+
+                    <property name="queryEntities">
+                        <list>
+                            <bean class="org.apache.ignite.cache.QueryEntity">
+                                <property name="keyType" value="java.lang.Long"/>
+                                <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Organization"/>
+                                <property name="fields">
+                                    <map>
+                                        <entry key="id" value="java.lang.Integer"/>
+                                        <entry key="name" value="java.lang.String"/>
+                                        <entry key="city" value="java.lang.String"/>
+                                    </map>
+                                </property>
+                            </bean>
+
+                            <bean class="org.apache.ignite.cache.QueryEntity">
+                                <property name="keyType" value="java.lang.Integer"/>
+                                <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/>
+                                <property name="fields">
+                                    <map>
+                                        <entry key="id" value="java.lang.Integer"/>
+                                        <entry key="name" value="java.lang.String"/>
+                                        <entry key="birthday" value="java.sql.Date"/>
+                                        <entry key="orgId" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fb74a98/modules/spring/src/test/config/jdbc-pojo-store-obj.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/config/jdbc-pojo-store-obj.xml b/modules/spring/src/test/config/jdbc-pojo-store-obj.xml
new file mode 100644
index 0000000..f628609
--- /dev/null
+++ b/modules/spring/src/test/config/jdbc-pojo-store-obj.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- This configuration was generated by GridGain Web Console (04/25/2016 14:59) -->
+
+<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 class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="gridName" value="test-cluster"/>
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <value>127.0.0.1:47500..47503</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="test-cache"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="readFromBackup" value="true"/>
+                    <property name="copyOnRead" value="true"/>
+
+                    <property name="cacheStoreFactory">
+                        <bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
+                            <property name="dataSourceFactory">
+                                <bean class="org.apache.ignite.cache.store.jdbc.H2DataSourceFactory"/>
+                            </property>
+
+                            <property name="dialect">
+                                <bean class="org.apache.ignite.cache.store.jdbc.dialect.H2Dialect"/>
+                            </property>
+                            <property name="types">
+                                <list>
+                                    <bean class="org.apache.ignite.cache.store.jdbc.JdbcType">
+                                        <property name="cacheName" value="test-cache"/>
+                                        <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.OrganizationKey"/>
+                                        <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Organization"/>
+                                        <property name="databaseSchema" value="PUBLIC"/>
+                                        <property name="databaseTable" value="ORGANIZATION"/>
+
+                                        <property name="keyFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="id"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.INTEGER"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="id"/>
+                                                    <property name="javaFieldType" value="java.lang.Integer"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+
+                                        <property name="valueFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="name"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="name"/>
+                                                    <property name="javaFieldType" value="java.lang.String"/>
+                                                </bean>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="city"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="city"/>
+                                                    <property name="javaFieldType" value="java.lang.String"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+                                    </bean>
+
+                                    <bean class="org.apache.ignite.cache.store.jdbc.JdbcType">
+                                        <property name="cacheName" value="test-cache"/>
+                                        <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.PersonKey"/>
+                                        <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/>
+                                        <property name="databaseSchema" value="PUBLIC"/>
+                                        <property name="databaseTable" value="PERSON"/>
+
+                                        <property name="keyFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="id"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.INTEGER"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="id"/>
+                                                    <property name="javaFieldType" value="java.lang.Integer"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+
+                                        <property name="valueFields">
+                                            <list>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="name"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="name"/>
+                                                    <property name="javaFieldType" value="java.lang.String"/>
+                                                </bean>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="birthday"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.DATE"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="birthday"/>
+                                                    <property name="javaFieldType" value="java.sql.Date"/>
+                                                </bean>
+                                                <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                                    <property name="databaseFieldName"
value="ORG_ID"/>
+                                                    <property name="databaseFieldType">
+                                                        <util:constant static-field="java.sql.Types.INTEGER"/>
+                                                    </property>
+                                                    <property name="javaFieldName" value="orgId"/>
+                                                    <property name="javaFieldType" value="java.lang.Integer"/>
+                                                </bean>
+                                            </list>
+                                        </property>
+                                    </bean>
+                                </list>
+                            </property>
+                        </bean>
+                    </property>
+
+                    <property name="readThrough" value="true"/>
+                    <property name="writeThrough" value="true"/>
+
+                    <property name="queryEntities">
+                        <list>
+                            <bean class="org.apache.ignite.cache.QueryEntity">
+                                <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.OrganizationKey"/>
+                                <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Organization"/>
+                                <property name="fields">
+                                    <map>
+                                        <entry key="id" value="java.lang.Integer"/>
+                                        <entry key="name" value="java.lang.String"/>
+                                        <entry key="city" value="java.lang.String"/>
+                                    </map>
+                                </property>
+                            </bean>
+
+                            <bean class="org.apache.ignite.cache.QueryEntity">
+                                <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.PersonKey"/>
+                                <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/>
+                                <property name="fields">
+                                    <map>
+                                        <entry key="id" value="java.lang.Integer"/>
+                                        <entry key="name" value="java.lang.String"/>
+                                        <entry key="birthday" value="java.sql.Date"/>
+                                        <entry key="orgId" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fb74a98/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
new file mode 100644
index 0000000..19644d4
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CachePojoStoreXmlSelfTest.java
@@ -0,0 +1,34 @@
+package org.apache.ignite.cache.store.jdbc;
+
+import java.net.URL;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteComponentType;
+import org.apache.ignite.internal.util.spring.IgniteSpringHelper;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+
+/**
+ * Tests for {@code PojoCacheStore} created via XML.
+ */
+public class CachePojoStoreXmlSelfTest extends CacheJdbcPojoStoreAbstractSelfTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        String path = builtinKeys ?  "modules/spring/src/test/config/jdbc-pojo-store-builtin.xml"
:
+            "modules/spring/src/test/config/jdbc-pojo-store-obj.xml";
+
+        URL url = U.resolveIgniteUrl(path);
+
+        IgniteSpringHelper spring = IgniteComponentType.SPRING.create(false);
+
+        IgniteConfiguration cfg = spring.loadConfigurations(url).get1().iterator().next();
+
+        cfg.setGridName(gridName);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Marshaller marshaller() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2fb74a98/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
new file mode 100644
index 0000000..d2feebb
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/H2DataSourceFactory.java
@@ -0,0 +1,18 @@
+package org.apache.ignite.cache.store.jdbc;
+
+import javax.cache.configuration.Factory;
+import javax.sql.DataSource;
+import org.h2.jdbcx.JdbcConnectionPool;
+
+/**
+ * Datasource to use for store tests.
+ */
+public class H2DataSourceFactory implements Factory<DataSource> {
+    /** DB connection URL. */
+    private static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1";
+
+    /** {@inheritDoc} */
+    @Override public DataSource create() {
+        return JdbcConnectionPool.create(DFLT_CONN_URL, "sa", "");
+    }
+}


Mime
View raw message