You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2019/12/30 16:18:47 UTC
[ignite] branch master updated: IGNITE-12513:SQL: Improve
QueryEntity field conflict message. This closes #7218.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 8ffb154 IGNITE-12513:SQL: Improve QueryEntity field conflict message. This closes #7218.
8ffb154 is described below
commit 8ffb1541b687d60c7b10b8140f46c3569e214559
Author: Andrey V. Mashenkov <an...@gmail.com>
AuthorDate: Mon Dec 30 19:18:13 2019 +0300
IGNITE-12513:SQL: Improve QueryEntity field conflict message. This closes #7218.
---
.../java/org/apache/ignite/cache/QueryEntity.java | 11 +++---
.../cache/query/QueryEntityTypeDescriptor.java | 41 ++++++++++------------
...finityKeyNameAndValueFieldNameConflictTest.java | 2 +-
3 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
index 769d74f..1bddf3c 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
@@ -17,7 +17,6 @@
package org.apache.ignite.cache;
-import javax.cache.CacheException;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -32,6 +31,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
+import javax.cache.CacheException;
import org.apache.ignite.cache.query.annotations.QueryGroupIndex;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cache.query.annotations.QueryTextField;
@@ -756,13 +756,10 @@ public class QueryEntity implements Serializable {
* @return Type descriptor.
*/
private static QueryEntityTypeDescriptor processKeyAndValueClasses(
- Class<?> keyCls,
- Class<?> valCls
+ @NotNull Class<?> keyCls,
+ @NotNull Class<?> valCls
) {
- QueryEntityTypeDescriptor d = new QueryEntityTypeDescriptor();
-
- d.keyClass(keyCls);
- d.valueClass(valCls);
+ QueryEntityTypeDescriptor d = new QueryEntityTypeDescriptor(keyCls, valCls);
processAnnotationsInClass(true, d.keyClass(), d, null);
processAnnotationsInClass(false, d.valueClass(), d, null);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java
index d8c0c39..814d707 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryEntityTypeDescriptor.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.NotNull;
/**
* Descriptor of type.
@@ -64,15 +65,26 @@ public class QueryEntityTypeDescriptor {
private QueryEntityIndexDescriptor fullTextIdx;
/** */
- private Class<?> keyCls;
+ private final Class<?> keyCls;
/** */
- private Class<?> valCls;
+ private final Class<?> valCls;
/** */
private boolean valTextIdx;
/**
+ * Constructor.
+ *
+ * @param keyCls QueryEntity key class.
+ * @param valCls QueryEntity value class.
+ */
+ public QueryEntityTypeDescriptor(@NotNull Class<?> keyCls, @NotNull Class<?> valCls) {
+ this.keyCls = keyCls;
+ this.valCls = valCls;
+ }
+
+ /**
* @return Indexes.
*/
public Map<String, GridQueryIndexDescriptor> indexes() {
@@ -140,15 +152,6 @@ public class QueryEntityTypeDescriptor {
}
/**
- * Sets value class.
- *
- * @param valCls Value class.
- */
- public void valueClass(Class<?> valCls) {
- this.valCls = valCls;
- }
-
- /**
* @return Key class.
*/
public Class<?> keyClass() {
@@ -156,15 +159,6 @@ public class QueryEntityTypeDescriptor {
}
/**
- * Set key class.
- *
- * @param keyCls Key class.
- */
- public void keyClass(Class<?> keyCls) {
- this.keyCls = keyCls;
- }
-
- /**
* Adds property to the type descriptor.
*
* @param prop Property.
@@ -174,8 +168,11 @@ public class QueryEntityTypeDescriptor {
public void addProperty(QueryEntityClassProperty prop, boolean key, boolean failOnDuplicate) {
String name = prop.fullName();
- if (props.put(name, prop) != null && failOnDuplicate)
- throw new CacheException("Property with name '" + name + "' already exists.");
+ if (props.put(name, prop) != null && failOnDuplicate) {
+ throw new CacheException("Property with name '" + name + "' already exists for " +
+ (key ? "key" : "value") + ": " +
+ "QueryEntity [key=" + keyCls.getName() + ", value=" + valCls.getName() + ']');
+ }
fields.put(name, prop.type());
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityKeyNameAndValueFieldNameConflictTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityKeyNameAndValueFieldNameConflictTest.java
index 276effb..8447677 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityKeyNameAndValueFieldNameConflictTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityKeyNameAndValueFieldNameConflictTest.java
@@ -143,7 +143,7 @@ public class AffinityKeyNameAndValueFieldNameConflictTest extends GridCommonAbst
return null;
}
- }, CacheException.class, "Property with name 'name' already exists.");
+ }, CacheException.class, "Property with name 'name' already exists for value");
}
/**