Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 77AD41021D for ; Mon, 21 Dec 2015 08:52:18 +0000 (UTC) Received: (qmail 97539 invoked by uid 500); 21 Dec 2015 08:52:18 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 97455 invoked by uid 500); 21 Dec 2015 08:52:18 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 97328 invoked by uid 99); 21 Dec 2015 08:52:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Dec 2015 08:52:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 27D83E049D; Mon, 21 Dec 2015 08:52:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: av@apache.org To: commits@ignite.apache.org Date: Mon, 21 Dec 2015 08:52:23 -0000 Message-Id: <78592e820d694db18f12733fc0aa5174@git.apache.org> In-Reply-To: <26a12b3a78f24b339335537cab929fe2@git.apache.org> References: <26a12b3a78f24b339335537cab929fe2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [6/8] ignite git commit: IGNITE-2169 Fixed incorrect null schema generation. IGNITE-2169 Fixed incorrect null schema generation. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/58b55b53 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/58b55b53 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/58b55b53 Branch: refs/heads/ignite-1.5.1-2 Commit: 58b55b53f15f0752c8fff97e31b94984a67d081b Parents: 0c7dfec Author: Alexey Kuznetsov Authored: Mon Dec 21 10:20:37 2015 +0700 Committer: Alexey Kuznetsov Committed: Mon Dec 21 10:20:37 2015 +0700 ---------------------------------------------------------------------- .../ignite/schema/generator/CodeGenerator.java | 7 +- .../schema/test/AbstractSchemaImportTest.java | 18 + .../org/apache/ignite/schema/test/model/Tst.txt | 506 +++++++++++++++++++ .../apache/ignite/schema/test/model/TstKey.txt | 96 ++++ .../schema/test/model/ignite-type-metadata.xml | 180 +++++++ .../test/parser/DbMetadataParserTest.java | 17 +- 6 files changed, 820 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/58b55b53/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java index 0e52acc..769c7d9 100644 --- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java +++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java @@ -606,8 +606,11 @@ public class CodeGenerator { add2(src, "jdbcType.setCacheName(cacheName);"); - // Database info. - add2(src, "jdbcType.setDatabaseSchema(\"" + pojo.schema() + "\");"); + // Database schema. + if (pojo.schema() != null) + add2(src, "jdbcType.setDatabaseSchema(\"" + pojo.schema() + "\");"); + + // Database table. add2(src, "jdbcType.setDatabaseTable(\"" + tbl + "\");"); // Java info. http://git-wip-us.apache.org/repos/asf/ignite/blob/58b55b53/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java index bf0f94a..97f0f87 100644 --- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java +++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java @@ -97,6 +97,24 @@ public abstract class AbstractSchemaImportTest extends TestCase { " tsCol TIMESTAMP," + " arrCol BINARY(10))"); + stmt.executeUpdate("CREATE SCHEMA IF NOT EXISTS TESTSCHEMA"); + + stmt.executeUpdate("CREATE TABLE IF NOT EXISTS TESTSCHEMA.TST(pk INTEGER PRIMARY KEY, " + + " boolCol BOOLEAN NOT NULL," + + " byteCol TINYINT NOT NULL," + + " shortCol SMALLINT NOT NULL," + + " intCol INTEGER NOT NULL, " + + " longCol BIGINT NOT NULL," + + " floatCol REAL NOT NULL," + + " doubleCol DOUBLE NOT NULL," + + " doubleCol2 DOUBLE NOT NULL, " + + " bigDecimalCol DECIMAL(10, 0)," + + " strCol VARCHAR(10)," + + " dateCol DATE," + + " timeCol TIME," + + " tsCol TIMESTAMP, " + + " arrCol BINARY(10))"); + conn.commit(); U.closeQuiet(stmt); http://git-wip-us.apache.org/repos/asf/ignite/blob/58b55b53/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Tst.txt ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Tst.txt b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Tst.txt new file mode 100644 index 0000000..23d61d0 --- /dev/null +++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Tst.txt @@ -0,0 +1,506 @@ +/* + * 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.schema.test.model; + +import java.io.*; + +/** + * Tst definition. + * + * Code generated by Apache Ignite Schema Import utility: 01/27/2015. + */ +public class Tst implements Serializable { + /** */ + private static final long serialVersionUID = 0L; + + /** Value for pk. */ + private int pk; + + /** Value for boolcol. */ + private boolean boolcol; + + /** Value for bytecol. */ + private byte bytecol; + + /** Value for shortcol. */ + private short shortcol; + + /** Value for intcol. */ + private int intcol; + + /** Value for longcol. */ + private long longcol; + + /** Value for floatcol. */ + private float floatcol; + + /** Value for doublecol. */ + private double doublecol; + + /** Value for doublecol2. */ + private double doublecol2; + + /** Value for bigdecimalcol. */ + private java.math.BigDecimal bigdecimalcol; + + /** Value for strcol. */ + private String strcol; + + /** Value for datecol. */ + private java.sql.Date datecol; + + /** Value for timecol. */ + private java.sql.Time timecol; + + /** Value for tscol. */ + private java.sql.Timestamp tscol; + + /** Value for arrcol. */ + private Object arrcol; + + /** + * Empty constructor. + */ + public Tst() { + // No-op. + } + + /** + * Full constructor. + */ + public Tst( + int pk, + boolean boolcol, + byte bytecol, + short shortcol, + int intcol, + long longcol, + float floatcol, + double doublecol, + double doublecol2, + java.math.BigDecimal bigdecimalcol, + String strcol, + java.sql.Date datecol, + java.sql.Time timecol, + java.sql.Timestamp tscol, + Object arrcol + ) { + this.pk = pk; + this.boolcol = boolcol; + this.bytecol = bytecol; + this.shortcol = shortcol; + this.intcol = intcol; + this.longcol = longcol; + this.floatcol = floatcol; + this.doublecol = doublecol; + this.doublecol2 = doublecol2; + this.bigdecimalcol = bigdecimalcol; + this.strcol = strcol; + this.datecol = datecol; + this.timecol = timecol; + this.tscol = tscol; + this.arrcol = arrcol; + } + + /** + * Gets pk. + * + * @return Value for pk. + */ + public int getPk() { + return pk; + } + + /** + * Sets pk. + * + * @param pk New value for pk. + */ + public void setPk(int pk) { + this.pk = pk; + } + + /** + * Gets boolcol. + * + * @return Value for boolcol. + */ + public boolean getBoolcol() { + return boolcol; + } + + /** + * Sets boolcol. + * + * @param boolcol New value for boolcol. + */ + public void setBoolcol(boolean boolcol) { + this.boolcol = boolcol; + } + + /** + * Gets bytecol. + * + * @return Value for bytecol. + */ + public byte getBytecol() { + return bytecol; + } + + /** + * Sets bytecol. + * + * @param bytecol New value for bytecol. + */ + public void setBytecol(byte bytecol) { + this.bytecol = bytecol; + } + + /** + * Gets shortcol. + * + * @return Value for shortcol. + */ + public short getShortcol() { + return shortcol; + } + + /** + * Sets shortcol. + * + * @param shortcol New value for shortcol. + */ + public void setShortcol(short shortcol) { + this.shortcol = shortcol; + } + + /** + * Gets intcol. + * + * @return Value for intcol. + */ + public int getIntcol() { + return intcol; + } + + /** + * Sets intcol. + * + * @param intcol New value for intcol. + */ + public void setIntcol(int intcol) { + this.intcol = intcol; + } + + /** + * Gets longcol. + * + * @return Value for longcol. + */ + public long getLongcol() { + return longcol; + } + + /** + * Sets longcol. + * + * @param longcol New value for longcol. + */ + public void setLongcol(long longcol) { + this.longcol = longcol; + } + + /** + * Gets floatcol. + * + * @return Value for floatcol. + */ + public float getFloatcol() { + return floatcol; + } + + /** + * Sets floatcol. + * + * @param floatcol New value for floatcol. + */ + public void setFloatcol(float floatcol) { + this.floatcol = floatcol; + } + + /** + * Gets doublecol. + * + * @return Value for doublecol. + */ + public double getDoublecol() { + return doublecol; + } + + /** + * Sets doublecol. + * + * @param doublecol New value for doublecol. + */ + public void setDoublecol(double doublecol) { + this.doublecol = doublecol; + } + + /** + * Gets doublecol2. + * + * @return Value for doublecol2. + */ + public double getDoublecol2() { + return doublecol2; + } + + /** + * Sets doublecol2. + * + * @param doublecol2 New value for doublecol2. + */ + public void setDoublecol2(double doublecol2) { + this.doublecol2 = doublecol2; + } + + /** + * Gets bigdecimalcol. + * + * @return Value for bigdecimalcol. + */ + public java.math.BigDecimal getBigdecimalcol() { + return bigdecimalcol; + } + + /** + * Sets bigdecimalcol. + * + * @param bigdecimalcol New value for bigdecimalcol. + */ + public void setBigdecimalcol(java.math.BigDecimal bigdecimalcol) { + this.bigdecimalcol = bigdecimalcol; + } + + /** + * Gets strcol. + * + * @return Value for strcol. + */ + public String getStrcol() { + return strcol; + } + + /** + * Sets strcol. + * + * @param strcol New value for strcol. + */ + public void setStrcol(String strcol) { + this.strcol = strcol; + } + + /** + * Gets datecol. + * + * @return Value for datecol. + */ + public java.sql.Date getDatecol() { + return datecol; + } + + /** + * Sets datecol. + * + * @param datecol New value for datecol. + */ + public void setDatecol(java.sql.Date datecol) { + this.datecol = datecol; + } + + /** + * Gets timecol. + * + * @return Value for timecol. + */ + public java.sql.Time getTimecol() { + return timecol; + } + + /** + * Sets timecol. + * + * @param timecol New value for timecol. + */ + public void setTimecol(java.sql.Time timecol) { + this.timecol = timecol; + } + + /** + * Gets tscol. + * + * @return Value for tscol. + */ + public java.sql.Timestamp getTscol() { + return tscol; + } + + /** + * Sets tscol. + * + * @param tscol New value for tscol. + */ + public void setTscol(java.sql.Timestamp tscol) { + this.tscol = tscol; + } + + /** + * Gets arrcol. + * + * @return Value for arrcol. + */ + public Object getArrcol() { + return arrcol; + } + + /** + * Sets arrcol. + * + * @param arrcol New value for arrcol. + */ + public void setArrcol(Object arrcol) { + this.arrcol = arrcol; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof Tst)) + return false; + + Tst that = (Tst)o; + + if (pk != that.pk) + return false; + + if (boolcol != that.boolcol) + return false; + + if (bytecol != that.bytecol) + return false; + + if (shortcol != that.shortcol) + return false; + + if (intcol != that.intcol) + return false; + + if (longcol != that.longcol) + return false; + + if (Float.compare(floatcol, that.floatcol) != 0) + return false; + + if (Double.compare(doublecol, that.doublecol) != 0) + return false; + + if (Double.compare(doublecol2, that.doublecol2) != 0) + return false; + + if (bigdecimalcol != null ? !bigdecimalcol.equals(that.bigdecimalcol) : that.bigdecimalcol != null) + return false; + + if (strcol != null ? !strcol.equals(that.strcol) : that.strcol != null) + return false; + + if (datecol != null ? !datecol.equals(that.datecol) : that.datecol != null) + return false; + + if (timecol != null ? !timecol.equals(that.timecol) : that.timecol != null) + return false; + + if (tscol != null ? !tscol.equals(that.tscol) : that.tscol != null) + return false; + + if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null) + return false; + + return true; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int res = pk; + + res = 31 * res + (boolcol ? 1 : 0); + + res = 31 * res + (int)bytecol; + + res = 31 * res + (int)shortcol; + + res = 31 * res + intcol; + + res = 31 * res + (int)(longcol ^ (longcol >>> 32)); + + res = 31 * res + (floatcol != +0.0f ? Float.floatToIntBits(floatcol) : 0); + + long ig_hash_temp = Double.doubleToLongBits(doublecol); + + res = 31 * res + (int)(ig_hash_temp ^ (ig_hash_temp >>> 32)); + + ig_hash_temp = Double.doubleToLongBits(doublecol2); + + res = 31 * res + (int)(ig_hash_temp ^ (ig_hash_temp >>> 32)); + + res = 31 * res + (bigdecimalcol != null ? bigdecimalcol.hashCode() : 0); + + res = 31 * res + (strcol != null ? strcol.hashCode() : 0); + + res = 31 * res + (datecol != null ? datecol.hashCode() : 0); + + res = 31 * res + (timecol != null ? timecol.hashCode() : 0); + + res = 31 * res + (tscol != null ? tscol.hashCode() : 0); + + res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0); + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Tst [pk=" + pk + + ", boolcol=" + boolcol + + ", bytecol=" + bytecol + + ", shortcol=" + shortcol + + ", intcol=" + intcol + + ", longcol=" + longcol + + ", floatcol=" + floatcol + + ", doublecol=" + doublecol + + ", doublecol2=" + doublecol2 + + ", bigdecimalcol=" + bigdecimalcol + + ", strcol=" + strcol + + ", datecol=" + datecol + + ", timecol=" + timecol + + ", tscol=" + tscol + + ", arrcol=" + arrcol + + "]"; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/58b55b53/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/TstKey.txt ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/TstKey.txt b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/TstKey.txt new file mode 100644 index 0000000..e2ce3c0 --- /dev/null +++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/TstKey.txt @@ -0,0 +1,96 @@ +/* + * 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.schema.test.model; + +import java.io.*; + +/** + * TstKey definition. + * + * Code generated by Apache Ignite Schema Import utility: 01/27/2015. + */ +public class TstKey implements Serializable { + /** */ + private static final long serialVersionUID = 0L; + + /** Value for pk. */ + private int pk; + + /** + * Empty constructor. + */ + public TstKey() { + // No-op. + } + + /** + * Full constructor. + */ + public TstKey( + int pk + ) { + this.pk = pk; + } + + /** + * Gets pk. + * + * @return Value for pk. + */ + public int getPk() { + return pk; + } + + /** + * Sets pk. + * + * @param pk New value for pk. + */ + public void setPk(int pk) { + this.pk = pk; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (!(o instanceof TstKey)) + return false; + + TstKey that = (TstKey)o; + + if (pk != that.pk) + return false; + + return true; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int res = pk; + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "TstKey [pk=" + pk + + "]"; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/58b55b53/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml index f03f24f..92d065c 100644 --- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml +++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml @@ -314,6 +314,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -393,4 +535,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/ignite/blob/58b55b53/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java index 6a2bf1d..a954029 100644 --- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java +++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java @@ -102,10 +102,19 @@ public class DbMetadataParserTest extends AbstractSchemaImportTest { } /** + * Check that type has not null full db name. + * + * @param type Type to check. + */ + public void checkSchemaHasFullDbName(PojoDescriptor type) { + assertNotNull("The DB schema should have a non-null fullDbName", type.fullDbName()); + } + + /** * Test that metadata generated correctly. */ public void testCheckMetadata() { - assertEquals("Metadata should contain 3 element", 3, pojos.size()); + assertEquals("Metadata should contain 5 elements", 5, pojos.size()); Iterator it = pojos.iterator(); @@ -117,5 +126,9 @@ public class DbMetadataParserTest extends AbstractSchemaImportTest { checkType(it.next()); checkType(it.next()); + + checkSchemaHasFullDbName(it.next()); + + checkType(it.next()); } -} \ No newline at end of file +}