ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [14/21] ignite git commit: IGNITE-3028 Implemented generation of fields aliases with database names in Schema Import Utility.
Date Mon, 25 Apr 2016 08:04:59 GMT
IGNITE-3028 Implemented generation of fields aliases with database names in Schema Import Utility.


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

Branch: refs/heads/ignite-1786
Commit: 2a64569c9beeceff2b48331166b839b38b991462
Parents: e1eb931
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Apr 22 16:08:46 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Apr 22 16:08:46 2016 +0700

----------------------------------------------------------------------
 .../ignite/schema/generator/CodeGenerator.java  | 26 ++++++++++-
 .../ignite/schema/generator/XmlGenerator.java   | 45 +++++++++++++++++---
 .../schema/parser/DatabaseMetadataParser.java   |  6 ++-
 .../ignite/schema/ui/SchemaImportApp.java       | 30 +++++++++----
 .../schema/test/AbstractSchemaImportTest.java   | 10 +++--
 .../schema/test/generator/XmlGeneratorTest.java |  4 +-
 .../apache/ignite/schema/test/model/Objects.txt | 31 +++++++++++++-
 .../ignite/schema/test/model/Primitives.txt     | 31 +++++++++++++-
 .../org/apache/ignite/schema/test/model/Tst.txt | 31 +++++++++++++-
 .../schema/test/model/ignite-type-metadata.xml  | 42 ++++++++++++++++++
 .../test/parser/DbMetadataParserTest.java       |  2 +-
 11 files changed, 232 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/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 68519d6..3ab0f4e 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
@@ -561,12 +561,13 @@ public class CodeGenerator {
      * @param pojos POJO descriptors.
      * @param pkg Types package.
      * @param includeKeys {@code true} if key fields should be included into value class.
+     * @param generateAliases {@code true} if aliases should be generated for query fields.
      * @param outFolder Output folder.
      * @param askOverwrite Callback to ask user to confirm file overwrite.
      * @throws IOException If generation failed.
      */
     public static void snippet(Collection<PojoDescriptor> pojos, String pkg, boolean
includeKeys,
-        String outFolder, ConfirmCallable askOverwrite) throws IOException {
+        boolean generateAliases, String outFolder, ConfirmCallable askOverwrite) throws IOException
{
         File pkgFolder = new File(outFolder, pkg.replace('.', File.separatorChar));
 
         File cacheCfg = new File(pkgFolder, "CacheConfig.java");
@@ -663,6 +664,29 @@ public class CodeGenerator {
             add2(src, "qryEntity.setFields(fields);");
             add0(src, "");
 
+            // Aliases.
+            if (generateAliases) {
+                Collection<PojoField> aliases = new ArrayList<>();
+
+                for (PojoField field : pojo.fields()) {
+                    if (!field.javaName().equalsIgnoreCase(field.dbName()))
+                        aliases.add(field);
+                }
+
+                if (!aliases.isEmpty()) {
+                    add2(src, "// Aliases for fields.");
+                    add2(src, "LinkedHashMap<String, String> aliases = new LinkedHashMap<>();");
+                    add0(src, "");
+
+                    for (PojoField alias : aliases)
+                        add2(src, "aliases.put(\"" + alias.javaName() + "\", \"" + alias.dbName()
+ "\");");
+
+                    add0(src, "");
+                    add2(src, "qryEntity.setAliases(aliases);");
+                    add0(src, "");
+                }
+            }
+
             // Indexes.
             Collection<QueryIndex> idxs = pojo.indexes();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
index a1665ae..bb5a0cb 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
@@ -209,6 +209,31 @@ public class XmlGenerator {
     }
 
     /**
+     * Add query field aliases to xml document.
+     *
+     * @param doc XML document.
+     * @param parent Parent XML node.
+     * @param fields Map with fields.
+     */
+    private static void addQueryFieldAliases(Document doc, Node parent, Collection<PojoField>
fields) {
+        Collection<PojoField> aliases = new ArrayList<>();
+
+        for (PojoField field : fields) {
+            if (!field.javaName().equalsIgnoreCase(field.dbName()))
+                aliases.add(field);
+        }
+
+        if (!aliases.isEmpty()) {
+            Element prop = addProperty(doc, parent, "aliases", null);
+
+            Element map = addElement(doc, prop, "util:map", "map-class", "java.util.LinkedHashMap");
+
+            for (PojoField alias : aliases)
+                addElement(doc, map, "entry", "key", alias.javaName(), "value", alias.dbName());
+        }
+    }
+
+    /**
      * Add indexes to xml document.
      *
      * @param doc XML document.
@@ -298,8 +323,9 @@ public class XmlGenerator {
      * @param parent Parent XML node.
      * @param pkg Package fo types.
      * @param pojo POJO descriptor.
+     * @param generateAliases {@code true} if aliases should be generated for query fields.
      */
-    private static void addQueryEntity(Document doc, Node parent, String pkg, PojoDescriptor
pojo) {
+    private static void addQueryEntity(Document doc, Node parent, String pkg, PojoDescriptor
pojo, boolean generateAliases) {
         Element bean = addBean(doc, parent, QueryEntity.class);
 
         addProperty(doc, bean, "keyType", pkg + "." + pojo.keyClassName());
@@ -310,6 +336,9 @@ public class XmlGenerator {
 
         addQueryFields(doc, bean, fields);
 
+        if (generateAliases)
+            addQueryFieldAliases(doc, bean, fields);
+
         addQueryIndexes(doc, bean, fields, pojo.indexes());
     }
 
@@ -318,12 +347,14 @@ public class XmlGenerator {
      *
      * @param pkg Package fo types.
      * @param pojo POJO descriptor.
+     * @param includeKeys {@code true} if key fields should be included into value class.
+     * @param generateAliases {@code true} if aliases should be generated for query fields.
      * @param out File to output result.
      * @param askOverwrite Callback to ask user to confirm file overwrite.
      */
-    public static void generate(String pkg, PojoDescriptor pojo, boolean includeKeys, File
out,
+    public static void generate(String pkg, PojoDescriptor pojo, boolean includeKeys, boolean
generateAliases, File out,
         ConfirmCallable askOverwrite) {
-        generate(pkg, Collections.singleton(pojo), includeKeys, out, askOverwrite);
+        generate(pkg, Collections.singleton(pojo), includeKeys, generateAliases, out, askOverwrite);
     }
 
     /**
@@ -331,11 +362,13 @@ public class XmlGenerator {
      *
      * @param pkg Package fo types.
      * @param pojos POJO descriptors.
+     * @param includeKeys {@code true} if key fields should be included into value class.
+     * @param generateAliases {@code true} if aliases should be generated for query fields.
      * @param out File to output result.
      * @param askOverwrite Callback to ask user to confirm file overwrite.
      */
-    public static void generate(String pkg, Collection<PojoDescriptor> pojos, boolean
includeKeys, File out,
-        ConfirmCallable askOverwrite) {
+    public static void generate(String pkg, Collection<PojoDescriptor> pojos, boolean
includeKeys,
+        boolean generateAliases, File out, ConfirmCallable askOverwrite) {
 
         File outFolder = out.getParentFile();
 
@@ -383,7 +416,7 @@ public class XmlGenerator {
                 addJdbcPojoStoreFactory(doc, typesItemsElem, pkg, pojo, includeKeys);
 
             for (PojoDescriptor pojo : pojos)
-                addQueryEntity(doc, beans, pkg, pojo);
+                addQueryEntity(doc, beans, pkg, pojo, generateAliases);
 
             TransformerFactory transformerFactory = TransformerFactory.newInstance();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
index b68f90d..c4490ef 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
@@ -128,8 +128,10 @@ public class DatabaseMetadataParser {
 
         List<PojoDescriptor> res = new ArrayList<>();
 
-        for (String schema : parents.keySet()) {
-            PojoDescriptor parent = parents.get(schema);
+        for (Map.Entry<String, PojoDescriptor> item : parents.entrySet()) {
+            String schema = item.getKey();
+            PojoDescriptor parent = item.getValue();
+
             Collection<PojoDescriptor> children = childrens.get(schema);
 
             if (!children.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
index 98ac357..36363dd 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
@@ -222,6 +222,9 @@ public class SchemaImportApp extends Application {
     private static final String PREF_POJO_CONSTRUCTOR = "pojo.constructor";
 
     /** */
+    private static final String PREF_GENERATE_ALIASES = "sql.aliases";
+
+    /** */
     private static final String PREF_XML_SINGLE = "xml.single";
 
     /** */
@@ -305,6 +308,9 @@ public class SchemaImportApp extends Application {
     private CheckBox pojoConstructorCh;
 
     /** */
+    private CheckBox generateAliasesCh;
+
+    /** */
     private CheckBox pojoIncludeKeysCh;
 
     /** */
@@ -604,9 +610,11 @@ public class SchemaImportApp extends Application {
 
         final File destFolder = new File(outFolder);
 
+        final boolean includeKeys = pojoIncludeKeysCh.isSelected();
+
         final boolean constructor = pojoConstructorCh.isSelected();
 
-        final boolean includeKeys = pojoIncludeKeysCh.isSelected();
+        final boolean generateAliases = generateAliasesCh.isSelected();
 
         final boolean singleXml = xmlSingleFileCh.isSelected();
 
@@ -656,16 +664,17 @@ public class SchemaImportApp extends Application {
 
                 for (PojoDescriptor pojo : all) {
                     if (!singleXml)
-                        XmlGenerator.generate(pkg, pojo, includeKeys, new File(destFolder,
pojo.table() + ".xml"),
-                            askOverwrite);
+                        XmlGenerator.generate(pkg, pojo, includeKeys, generateAliases,
+                            new File(destFolder, pojo.table() + ".xml"), askOverwrite);
 
                     CodeGenerator.pojos(pojo, outFolder, pkg, constructor, includeKeys, askOverwrite);
                 }
 
                 if (singleXml)
-                    XmlGenerator.generate(pkg, all, includeKeys, new File(outFolder, "ignite-type-metadata.xml"),
askOverwrite);
+                    XmlGenerator.generate(pkg, all, includeKeys, generateAliases,
+                        new File(outFolder, "ignite-type-metadata.xml"), askOverwrite);
 
-                CodeGenerator.snippet(all, pkg, includeKeys, outFolder, askOverwrite);
+                CodeGenerator.snippet(all, pkg, includeKeys, generateAliases, outFolder,
askOverwrite);
 
                 perceptualDelay(started);
 
@@ -778,7 +787,7 @@ public class SchemaImportApp extends Application {
                     String p1 = part1[idx];
                     String p2 = part2[idx];
 
-                    int cmp = p1.matches("\\d+") && p2.matches("\\d+") ? new Integer(p1).compareTo(new
Integer(p2)) :
+                    int cmp = p1.matches("\\d+") && p2.matches("\\d+") ? Integer.valueOf(p1).compareTo(Integer.valueOf(p2))
:
                             part1[idx].compareTo(part2[idx]);
 
                     if (cmp != 0)
@@ -796,7 +805,7 @@ public class SchemaImportApp extends Application {
                     while (idx < parts.length) {
                         String p = parts[idx];
 
-                        int cmp = p.matches("\\d+") ? new Integer(p).compareTo(0) : 1;
+                        int cmp = p.matches("\\d+") ? Integer.valueOf(p).compareTo(0) : 1;
 
                         if (cmp != 0) return left ? cmp : -cmp;
 
@@ -1228,7 +1237,7 @@ public class SchemaImportApp extends Application {
         genPnl.addColumn(35, 35, 35, Priority.NEVER);
 
         genPnl.addRow(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
-        genPnl.addRows(7);
+        genPnl.addRows(8);
 
         TableColumn<PojoDescriptor, Boolean> useCol = customColumn("Schema / Table",
"use",
             "If checked then this table will be used for XML and POJOs generation", PojoDescriptorCell.cellFactory());
@@ -1343,6 +1352,9 @@ public class SchemaImportApp extends Application {
         pojoConstructorCh = genPnl.add(checkBox("Generate constructors for POJOs",
             "If selected then generate empty and full constructors for POJOs", false), 3);
 
+        generateAliasesCh = genPnl.add(checkBox("Generate aliases for SQL fields",
+            "If selected then generate aliases for SQL fields with db names", true), 3);
+
         xmlSingleFileCh = genPnl.add(checkBox("Write all configurations to a single XML file",
             "If selected then all configurations will be saved into the file 'ignite-type-metadata.xml'",
true), 3);
 
@@ -1836,6 +1848,7 @@ public class SchemaImportApp extends Application {
         pkgTf.setText(getStringProp(PREF_POJO_PACKAGE, "org.apache.ignite"));
         pojoIncludeKeysCh.setSelected(getBoolProp(PREF_POJO_INCLUDE, true));
         pojoConstructorCh.setSelected(getBoolProp(PREF_POJO_CONSTRUCTOR, false));
+        generateAliasesCh.setSelected(getBoolProp(PREF_GENERATE_ALIASES, true));
 
         xmlSingleFileCh.setSelected(getBoolProp(PREF_XML_SINGLE, true));
 
@@ -1901,6 +1914,7 @@ public class SchemaImportApp extends Application {
         setStringProp(PREF_POJO_PACKAGE, pkgTf.getText());
         setBoolProp(PREF_POJO_INCLUDE, pojoIncludeKeysCh.isSelected());
         setBoolProp(PREF_POJO_CONSTRUCTOR, pojoConstructorCh.isSelected());
+        setBoolProp(PREF_GENERATE_ALIASES, generateAliasesCh.isSelected());
 
         setBoolProp(PREF_XML_SINGLE, xmlSingleFileCh.isSelected());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/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 97f0f87..d4534be 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
@@ -79,7 +79,8 @@ public abstract class AbstractSchemaImportTest extends TestCase {
             " dateCol DATE," +
             " timeCol TIME," +
             " tsCol TIMESTAMP, " +
-            " arrCol BINARY(10))");
+            " arrCol BINARY(10)," +
+            " FIELD_WITH_ALIAS VARCHAR(10))");
 
         stmt.executeUpdate("CREATE TABLE IF NOT EXISTS OBJECTS (pk INTEGER PRIMARY KEY, "
+
             " boolCol BOOLEAN," +
@@ -95,7 +96,8 @@ public abstract class AbstractSchemaImportTest extends TestCase {
             " dateCol DATE," +
             " timeCol TIME," +
             " tsCol TIMESTAMP," +
-            " arrCol BINARY(10))");
+            " arrCol BINARY(10)," +
+            " FIELD_WITH_ALIAS VARCHAR(10))");
 
         stmt.executeUpdate("CREATE SCHEMA IF NOT EXISTS TESTSCHEMA");
 
@@ -113,7 +115,8 @@ public abstract class AbstractSchemaImportTest extends TestCase {
             " dateCol DATE," +
             " timeCol TIME," +
             " tsCol TIMESTAMP, " +
-            " arrCol BINARY(10))");
+            " arrCol BINARY(10)," +
+            " FIELD_WITH_ALIAS VARCHAR(10))");
 
         conn.commit();
 
@@ -144,6 +147,7 @@ public abstract class AbstractSchemaImportTest extends TestCase {
 
                     if (!baseLine.equals(generatedLine) && !baseLine.contains(excludePtrn)
                             && !generatedLine.contains(excludePtrn)) {
+                        System.out.println("Generated file: " + generated.toString());
                         System.out.println("Expected: " + baseLine);
                         System.out.println("Generated: " + generatedLine);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
index 9a1356b..2ed36e9 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
@@ -40,11 +40,11 @@ public class XmlGeneratorTest extends AbstractSchemaImportTest {
 
         String fileName = "ignite-type-metadata.xml";
 
-        XmlGenerator.generate("org.apache.ignite.schema.test.model", all, true, new File(OUT_DIR_PATH,
fileName),
+        XmlGenerator.generate("org.apache.ignite.schema.test.model", all, true, true, new
File(OUT_DIR_PATH, fileName),
             askOverwrite);
 
         assertTrue("Generated XML file content is differ from expected one",
             compareFilesInt(getClass().getResourceAsStream("/org/apache/ignite/schema/test/model/"
+ fileName),
                 new File(OUT_DIR_PATH + "/" + fileName), "XML generated by Apache Ignite
Schema Import utility"));
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
index c448ab5..380191b 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
@@ -73,6 +73,9 @@ public class Objects implements Serializable {
     /** Value for arrcol. */
     private Object arrcol;
 
+    /** Value for fieldWithAlias. */
+    private String fieldWithAlias;
+
     /**
      * Empty constructor.
      */
@@ -98,7 +101,8 @@ public class Objects implements Serializable {
         java.sql.Date datecol,
         java.sql.Time timecol,
         java.sql.Timestamp tscol,
-        Object arrcol
+        Object arrcol,
+        String fieldWithAlias
     ) {
         this.pk = pk;
         this.boolcol = boolcol;
@@ -115,6 +119,7 @@ public class Objects implements Serializable {
         this.timecol = timecol;
         this.tscol = tscol;
         this.arrcol = arrcol;
+        this.fieldWithAlias = fieldWithAlias;
     }
 
     /**
@@ -387,6 +392,24 @@ public class Objects implements Serializable {
         this.arrcol = arrcol;
     }
 
+    /**
+     * Gets fieldWithAlias.
+     *
+     * @return Value for fieldWithAlias.
+     */
+    public String getFieldWithAlias() {
+        return fieldWithAlias;
+    }
+
+    /**
+     * Sets fieldWithAlias.
+     *
+     * @param fieldWithAlias New value for fieldWithAlias.
+     */
+    public void setFieldWithAlias(String fieldWithAlias) {
+        this.fieldWithAlias = fieldWithAlias;
+    }
+
     /** {@inheritDoc} */
     @Override public boolean equals(Object o) {
         if (this == o)
@@ -442,6 +465,9 @@ public class Objects implements Serializable {
         if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null)
             return false;
 
+        if (fieldWithAlias != null ? !fieldWithAlias.equals(that.fieldWithAlias) : that.fieldWithAlias
!= null)
+            return false;
+
         return true;
     }
 
@@ -477,6 +503,8 @@ public class Objects implements Serializable {
 
         res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0);
 
+        res = 31 * res + (fieldWithAlias != null ? fieldWithAlias.hashCode() : 0);
+
         return res;
     }
 
@@ -497,6 +525,7 @@ public class Objects implements Serializable {
             ", timecol=" + timecol +
             ", tscol=" + tscol +
             ", arrcol=" + arrcol +
+            ", fieldWithAlias=" + fieldWithAlias +
             "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
index ef8f902..a07b379 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
@@ -73,6 +73,9 @@ public class Primitives implements Serializable {
     /** Value for arrcol. */
     private Object arrcol;
 
+    /** Value for fieldWithAlias. */
+    private String fieldWithAlias;
+
     /**
      * Empty constructor.
      */
@@ -98,7 +101,8 @@ public class Primitives implements Serializable {
         java.sql.Date datecol,
         java.sql.Time timecol,
         java.sql.Timestamp tscol,
-        Object arrcol
+        Object arrcol,
+        String fieldWithAlias
     ) {
         this.pk = pk;
         this.boolcol = boolcol;
@@ -115,6 +119,7 @@ public class Primitives implements Serializable {
         this.timecol = timecol;
         this.tscol = tscol;
         this.arrcol = arrcol;
+        this.fieldWithAlias = fieldWithAlias;
     }
 
     /**
@@ -387,6 +392,24 @@ public class Primitives implements Serializable {
         this.arrcol = arrcol;
     }
 
+    /**
+     * Gets fieldWithAlias.
+     *
+     * @return Value for fieldWithAlias.
+     */
+    public String getFieldWithAlias() {
+        return fieldWithAlias;
+    }
+
+    /**
+     * Sets fieldWithAlias.
+     *
+     * @param fieldWithAlias New value for fieldWithAlias.
+     */
+    public void setFieldWithAlias(String fieldWithAlias) {
+        this.fieldWithAlias = fieldWithAlias;
+    }
+
     /** {@inheritDoc} */
     @Override public boolean equals(Object o) {
         if (this == o)
@@ -442,6 +465,9 @@ public class Primitives implements Serializable {
         if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null)
             return false;
 
+        if (fieldWithAlias != null ? !fieldWithAlias.equals(that.fieldWithAlias) : that.fieldWithAlias
!= null)
+            return false;
+
         return true;
     }
 
@@ -481,6 +507,8 @@ public class Primitives implements Serializable {
 
         res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0);
 
+        res = 31 * res + (fieldWithAlias != null ? fieldWithAlias.hashCode() : 0);
+
         return res;
     }
 
@@ -501,6 +529,7 @@ public class Primitives implements Serializable {
             ", timecol=" + timecol +
             ", tscol=" + tscol +
             ", arrcol=" + arrcol +
+            ", fieldWithAlias=" + fieldWithAlias +
             "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/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
index 23d61d0..f1db255 100644
--- 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
@@ -73,6 +73,9 @@ public class Tst implements Serializable {
     /** Value for arrcol. */
     private Object arrcol;
 
+    /** Value for fieldWithAlias. */
+    private String fieldWithAlias;
+
     /**
      * Empty constructor.
      */
@@ -98,7 +101,8 @@ public class Tst implements Serializable {
         java.sql.Date datecol,
         java.sql.Time timecol,
         java.sql.Timestamp tscol,
-        Object arrcol
+        Object arrcol,
+        String fieldWithAlias
     ) {
         this.pk = pk;
         this.boolcol = boolcol;
@@ -115,6 +119,7 @@ public class Tst implements Serializable {
         this.timecol = timecol;
         this.tscol = tscol;
         this.arrcol = arrcol;
+        this.fieldWithAlias = fieldWithAlias;
     }
 
     /**
@@ -387,6 +392,24 @@ public class Tst implements Serializable {
         this.arrcol = arrcol;
     }
 
+    /**
+     * Gets fieldWithAlias.
+     *
+     * @return Value for fieldWithAlias.
+     */
+    public String getFieldWithAlias() {
+        return fieldWithAlias;
+    }
+
+    /**
+     * Sets fieldWithAlias.
+     *
+     * @param fieldWithAlias New value for fieldWithAlias.
+     */
+    public void setFieldWithAlias(String fieldWithAlias) {
+        this.fieldWithAlias = fieldWithAlias;
+    }
+
     /** {@inheritDoc} */
     @Override public boolean equals(Object o) {
         if (this == o)
@@ -442,6 +465,9 @@ public class Tst implements Serializable {
         if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null)
             return false;
 
+        if (fieldWithAlias != null ? !fieldWithAlias.equals(that.fieldWithAlias) : that.fieldWithAlias
!= null)
+            return false;
+
         return true;
     }
 
@@ -481,6 +507,8 @@ public class Tst implements Serializable {
 
         res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0);
 
+        res = 31 * res + (fieldWithAlias != null ? fieldWithAlias.hashCode() : 0);
+
         return res;
     }
 
@@ -501,6 +529,7 @@ public class Tst implements Serializable {
             ", timecol=" + timecol +
             ", tscol=" + tscol +
             ", arrcol=" + arrcol +
+            ", fieldWithAlias=" + fieldWithAlias +
             "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/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 95706ef..fd14ae2 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
@@ -169,6 +169,14 @@
                                 <property name="javaFieldType" value="java.lang.Object"/>
                                 <property name="javaFieldName" value="arrcol"/>
                             </bean>
+                            <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                <property name="databaseFieldType">
+                                    <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                </property>
+                                <property name="databaseFieldName" value="FIELD_WITH_ALIAS"/>
+                                <property name="javaFieldType" value="java.lang.String"/>
+                                <property name="javaFieldName" value="fieldWithAlias"/>
+                            </bean>
                         </list>
                     </property>
                 </bean>
@@ -311,6 +319,14 @@
                                 <property name="javaFieldType" value="java.lang.Object"/>
                                 <property name="javaFieldName" value="arrcol"/>
                             </bean>
+                            <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                <property name="databaseFieldType">
+                                    <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                </property>
+                                <property name="databaseFieldName" value="FIELD_WITH_ALIAS"/>
+                                <property name="javaFieldType" value="java.lang.String"/>
+                                <property name="javaFieldName" value="fieldWithAlias"/>
+                            </bean>
                         </list>
                     </property>
                 </bean>
@@ -453,6 +469,14 @@
                                 <property name="javaFieldType" value="java.lang.Object"/>
                                 <property name="javaFieldName" value="arrcol"/>
                             </bean>
+                            <bean class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
+                                <property name="databaseFieldType">
+                                    <util:constant static-field="java.sql.Types.VARCHAR"/>
+                                </property>
+                                <property name="databaseFieldName" value="FIELD_WITH_ALIAS"/>
+                                <property name="javaFieldType" value="java.lang.String"/>
+                                <property name="javaFieldName" value="fieldWithAlias"/>
+                            </bean>
                         </list>
                     </property>
                 </bean>
@@ -479,6 +503,12 @@
                 <entry key="timecol" value="java.sql.Time"/>
                 <entry key="tscol" value="java.sql.Timestamp"/>
                 <entry key="arrcol" value="java.lang.Object"/>
+                <entry key="fieldWithAlias" value="java.lang.String"/>
+            </util:map>
+        </property>
+        <property name="aliases">
+            <util:map map-class="java.util.LinkedHashMap">
+                <entry key="fieldWithAlias" value="FIELD_WITH_ALIAS"/>
             </util:map>
         </property>
         <property name="indexes">
@@ -517,6 +547,12 @@
                 <entry key="timecol" value="java.sql.Time"/>
                 <entry key="tscol" value="java.sql.Timestamp"/>
                 <entry key="arrcol" value="java.lang.Object"/>
+                <entry key="fieldWithAlias" value="java.lang.String"/>
+            </util:map>
+        </property>
+        <property name="aliases">
+            <util:map map-class="java.util.LinkedHashMap">
+                <entry key="fieldWithAlias" value="FIELD_WITH_ALIAS"/>
             </util:map>
         </property>
         <property name="indexes">
@@ -555,6 +591,12 @@
                 <entry key="timecol" value="java.sql.Time"/>
                 <entry key="tscol" value="java.sql.Timestamp"/>
                 <entry key="arrcol" value="java.lang.Object"/>
+                <entry key="fieldWithAlias" value="java.lang.String"/>
+            </util:map>
+        </property>
+        <property name="aliases">
+            <util:map map-class="java.util.LinkedHashMap">
+                <entry key="fieldWithAlias" value="FIELD_WITH_ALIAS"/>
             </util:map>
         </property>
         <property name="indexes">

http://git-wip-us.apache.org/repos/asf/ignite/blob/2a64569c/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 a954029..f918012 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
@@ -66,7 +66,7 @@ public class DbMetadataParserTest extends AbstractSchemaImportTest {
 
         List<PojoField> fields = type.fields();
 
-        assertEquals("Value type should have 15 fields", 15, fields.size());
+        assertEquals("Value type should have 15 fields", 16, fields.size());
 
         Iterator<PojoField> fieldsIt = fields.iterator();
 


Mime
View raw message