You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/10/08 05:05:58 UTC

[GitHub] [ignite] aries-3 opened a new pull request #8328: IGNITE-13028 Spring Data integration introspects the fields of the key object

aries-3 opened a new pull request #8328:
URL: https://github.com/apache/ignite/pull/8328


   In IgniteQueryGenerator added searching key fields among field of key-class. 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] asfgit closed pull request #8328: IGNITE-13028 Spring Data integration introspects the fields of the key object

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #8328:
URL: https://github.com/apache/ignite/pull/8328


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] alamar commented on a change in pull request #8328: IGNITE-13028 Spring Data integration introspects the fields of the key object

Posted by GitBox <gi...@apache.org>.
alamar commented on a change in pull request #8328:
URL: https://github.com/apache/ignite/pull/8328#discussion_r505396015



##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCompoundKeyTest.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Optional;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata.compoundkey.City;
+import org.apache.ignite.springdata.compoundkey.CityKey;
+import org.apache.ignite.springdata.compoundkey.CityRepository;
+import org.apache.ignite.springdata.compoundkey.CompoundKeyApplicationConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using conpoud key in spring-data
+ * */
+public class IgniteSpringDataCompoundKeyTest extends GridCommonAbstractTest {
+
+    /** Application context */

Review comment:
       blank line NOT needed at the start of class

##########
File path: modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/query/IgniteQueryGenerator.java
##########
@@ -39,7 +41,13 @@ private IgniteQueryGenerator() {
      * @return Generated ignite query.
      */
     public static IgniteQuery generateSql(Method mtd, RepositoryMetadata metadata) {
-        PartTree parts = new PartTree(mtd.getName(), metadata.getDomainType());
+        PartTree parts;
+        try {

Review comment:
       blank line is probably needed above

##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCompoundKeyTest.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Optional;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata.compoundkey.City;
+import org.apache.ignite.springdata.compoundkey.CityKey;
+import org.apache.ignite.springdata.compoundkey.CityRepository;
+import org.apache.ignite.springdata.compoundkey.CompoundKeyApplicationConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using conpoud key in spring-data
+ * */
+public class IgniteSpringDataCompoundKeyTest extends GridCommonAbstractTest {
+
+    /** Application context */
+    private static AnnotationConfigApplicationContext ctx;
+
+    /** City repository */
+    private static CityRepository repo;
+
+    /** Cache name */
+    private static final String CACHE_NAME = "City";
+
+    /** Cities count */
+    private static final int TOTAL_COUNT = 5;
+
+    /** Count Afganistan cities */
+    private static final int AFG_COUNT = 4;
+
+    /** Kabul identifier */
+    private static final int KABUL_ID = 1;
+
+    /** Quandahar identifier */
+    private static final int QUANDAHAR_ID = 2;
+
+    /** Afganistan county code */
+    private static final String AFG = "AFG";
+
+    /** test city Kabul */
+    private static final City KABUL = new City("Kabul", "Kabol", 1780000);
+
+    /** test city Quandahar */
+    private static final City QUANDAHAR = new City("Qandahar","Qandahar", 237500);
+
+    /**
+     * Performs context initialization before tests.
+     */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+        ctx = new AnnotationConfigApplicationContext();
+        ctx.register(CompoundKeyApplicationConfiguration.class);
+        ctx.refresh();
+        repo = ctx.getBean(CityRepository.class);
+    }
+
+    /**
+     * Load data
+     * */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+        loadData();

Review comment:
       blank line above and below

##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCompoundKeyTest.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Optional;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata.compoundkey.City;
+import org.apache.ignite.springdata.compoundkey.CityKey;
+import org.apache.ignite.springdata.compoundkey.CityRepository;
+import org.apache.ignite.springdata.compoundkey.CompoundKeyApplicationConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using conpoud key in spring-data
+ * */
+public class IgniteSpringDataCompoundKeyTest extends GridCommonAbstractTest {
+
+    /** Application context */
+    private static AnnotationConfigApplicationContext ctx;
+
+    /** City repository */
+    private static CityRepository repo;
+
+    /** Cache name */
+    private static final String CACHE_NAME = "City";
+
+    /** Cities count */
+    private static final int TOTAL_COUNT = 5;
+
+    /** Count Afganistan cities */
+    private static final int AFG_COUNT = 4;
+
+    /** Kabul identifier */
+    private static final int KABUL_ID = 1;
+
+    /** Quandahar identifier */
+    private static final int QUANDAHAR_ID = 2;
+
+    /** Afganistan county code */
+    private static final String AFG = "AFG";
+
+    /** test city Kabul */
+    private static final City KABUL = new City("Kabul", "Kabol", 1780000);
+
+    /** test city Quandahar */
+    private static final City QUANDAHAR = new City("Qandahar","Qandahar", 237500);
+
+    /**
+     * Performs context initialization before tests.
+     */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+        ctx = new AnnotationConfigApplicationContext();
+        ctx.register(CompoundKeyApplicationConfiguration.class);
+        ctx.refresh();
+        repo = ctx.getBean(CityRepository.class);
+    }
+
+    /**
+     * Load data
+     * */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+        loadData();
+        assertEquals(TOTAL_COUNT, repo.count());
+    }
+
+    /**
+     * Performs context destroy after tests.
+     */
+    @Override protected void afterTestsStopped() {
+        ctx.close();
+    }
+
+    /** load data*/
+    public void loadData() throws Exception {
+        Ignite ignite = ctx.getBean(Ignite.class);
+        if (ignite.cacheNames().contains(CACHE_NAME))

Review comment:
       blank line above

##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCompoundKeyTest.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Optional;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata.compoundkey.City;
+import org.apache.ignite.springdata.compoundkey.CityKey;
+import org.apache.ignite.springdata.compoundkey.CityRepository;
+import org.apache.ignite.springdata.compoundkey.CompoundKeyApplicationConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using conpoud key in spring-data
+ * */
+public class IgniteSpringDataCompoundKeyTest extends GridCommonAbstractTest {
+
+    /** Application context */
+    private static AnnotationConfigApplicationContext ctx;
+
+    /** City repository */
+    private static CityRepository repo;
+
+    /** Cache name */
+    private static final String CACHE_NAME = "City";
+
+    /** Cities count */
+    private static final int TOTAL_COUNT = 5;
+
+    /** Count Afganistan cities */
+    private static final int AFG_COUNT = 4;
+
+    /** Kabul identifier */
+    private static final int KABUL_ID = 1;
+
+    /** Quandahar identifier */
+    private static final int QUANDAHAR_ID = 2;
+
+    /** Afganistan county code */
+    private static final String AFG = "AFG";
+
+    /** test city Kabul */
+    private static final City KABUL = new City("Kabul", "Kabol", 1780000);
+
+    /** test city Quandahar */
+    private static final City QUANDAHAR = new City("Qandahar","Qandahar", 237500);
+
+    /**
+     * Performs context initialization before tests.
+     */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+        ctx = new AnnotationConfigApplicationContext();

Review comment:
       blank line

##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/compoundkey/CityKey.java
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springdata.compoundkey;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+
+/** Compound key for city class  */
+public class CityKey implements Serializable {
+

Review comment:
       etc, etc

##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCompoundKeyTest.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Optional;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata.compoundkey.City;
+import org.apache.ignite.springdata.compoundkey.CityKey;
+import org.apache.ignite.springdata.compoundkey.CityRepository;
+import org.apache.ignite.springdata.compoundkey.CompoundKeyApplicationConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using conpoud key in spring-data
+ * */
+public class IgniteSpringDataCompoundKeyTest extends GridCommonAbstractTest {
+
+    /** Application context */
+    private static AnnotationConfigApplicationContext ctx;
+
+    /** City repository */
+    private static CityRepository repo;
+
+    /** Cache name */
+    private static final String CACHE_NAME = "City";
+
+    /** Cities count */
+    private static final int TOTAL_COUNT = 5;
+
+    /** Count Afganistan cities */
+    private static final int AFG_COUNT = 4;
+
+    /** Kabul identifier */
+    private static final int KABUL_ID = 1;
+
+    /** Quandahar identifier */
+    private static final int QUANDAHAR_ID = 2;
+
+    /** Afganistan county code */
+    private static final String AFG = "AFG";
+
+    /** test city Kabul */
+    private static final City KABUL = new City("Kabul", "Kabol", 1780000);
+
+    /** test city Quandahar */
+    private static final City QUANDAHAR = new City("Qandahar","Qandahar", 237500);
+
+    /**
+     * Performs context initialization before tests.
+     */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+        ctx = new AnnotationConfigApplicationContext();
+        ctx.register(CompoundKeyApplicationConfiguration.class);
+        ctx.refresh();
+        repo = ctx.getBean(CityRepository.class);
+    }
+
+    /**
+     * Load data
+     * */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+        loadData();
+        assertEquals(TOTAL_COUNT, repo.count());
+    }
+
+    /**
+     * Performs context destroy after tests.
+     */
+    @Override protected void afterTestsStopped() {
+        ctx.close();
+    }
+
+    /** load data*/
+    public void loadData() throws Exception {
+        Ignite ignite = ctx.getBean(Ignite.class);
+        if (ignite.cacheNames().contains(CACHE_NAME))
+            ignite.destroyCache(CACHE_NAME);
+
+        try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
+            Statement st = conn.createStatement();
+            st.execute("DROP TABLE IF EXISTS City");

Review comment:
       blank line above

##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCompoundKeyTest.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.springdata;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Optional;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata.compoundkey.City;
+import org.apache.ignite.springdata.compoundkey.CityKey;
+import org.apache.ignite.springdata.compoundkey.CityRepository;
+import org.apache.ignite.springdata.compoundkey.CompoundKeyApplicationConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using conpoud key in spring-data
+ * */
+public class IgniteSpringDataCompoundKeyTest extends GridCommonAbstractTest {
+
+    /** Application context */
+    private static AnnotationConfigApplicationContext ctx;
+
+    /** City repository */
+    private static CityRepository repo;
+
+    /** Cache name */
+    private static final String CACHE_NAME = "City";
+
+    /** Cities count */
+    private static final int TOTAL_COUNT = 5;
+
+    /** Count Afganistan cities */
+    private static final int AFG_COUNT = 4;
+
+    /** Kabul identifier */
+    private static final int KABUL_ID = 1;
+
+    /** Quandahar identifier */
+    private static final int QUANDAHAR_ID = 2;
+
+    /** Afganistan county code */
+    private static final String AFG = "AFG";
+
+    /** test city Kabul */
+    private static final City KABUL = new City("Kabul", "Kabol", 1780000);
+
+    /** test city Quandahar */
+    private static final City QUANDAHAR = new City("Qandahar","Qandahar", 237500);
+
+    /**
+     * Performs context initialization before tests.
+     */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+        ctx = new AnnotationConfigApplicationContext();
+        ctx.register(CompoundKeyApplicationConfiguration.class);
+        ctx.refresh();
+        repo = ctx.getBean(CityRepository.class);

Review comment:
       blank line

##########
File path: modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/query/IgniteQueryGenerator.java
##########
@@ -175,13 +183,24 @@ else if (Pageable.class.isAssignableFrom(type))
         return option;
     }
 
+    /**
+     * Check and correct table name if using column name from compound key.
+     */
+    private static String getColumnName(Part part, Class<?> domainType) {
+        PropertyPath prperty = part.getProperty();
+        if (prperty.getType() != domainType)

Review comment:
       blank line

##########
File path: modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/compoundkey/City.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.springdata.compoundkey;
+
+import java.util.Objects;
+
+/**
+ * Value-class
+ * */
+public class City {
+

Review comment:
       blank line not needed, etc




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org