http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/QuerySplitterTest.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/QuerySplitterTest.java 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/QuerySplitterTest.java
index 8e4842c..a67dc63 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/QuerySplitterTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/QuerySplitterTest.java
@@ -43,7 +43,7 @@ public class QuerySplitterTest extends JdbcTestCase {
                Table customersTable = schema.getTableByName("CUSTOMERS");
                Query q = new Query().from(employeesTable, 
"e").from(customersTable,
                                "c");
-               q.select(employeesTable.getColumns()[0], 
customersTable.getColumns()[0]);
+               q.select(employeesTable.getColumns().get(0), 
customersTable.getColumns().get(0));
                assertEquals(
                                "SELECT e._EMPLOYEENUMBER_, c._CUSTOMERNUMBER_ 
FROM PUBLIC._EMPLOYEES_ e, PUBLIC._CUSTOMERS_ c",
                                q.toString().replace('\"', '_'));
@@ -83,10 +83,10 @@ public class QuerySplitterTest extends JdbcTestCase {
                Table orderDetailsTable = schema.getTableByName("ORDERDETAILS");
                Query q = new Query().from(employeesTable, 
"e").from(orderDetailsTable,
                                "c");
-               q.select(orderDetailsTable.getColumns()[0])
+               q.select(orderDetailsTable.getColumns().get(0))
                                .select(new SelectItem(FunctionType.MAX, 
employeesTable
-                                               .getColumns()[0]));
-               q.groupBy(orderDetailsTable.getColumns()[0]);
+                                               .getColumns().get(0)));
+               q.groupBy(orderDetailsTable.getColumns().get(0));
                assertEquals(
                                "SELECT c._ORDERNUMBER_, 
MAX(e._EMPLOYEENUMBER_) FROM PUBLIC._EMPLOYEES_ e, PUBLIC._ORDERDETAILS_ c 
GROUP BY c._ORDERNUMBER_",
                                q.toString().replace('\"', '_'));
@@ -121,8 +121,7 @@ public class QuerySplitterTest extends JdbcTestCase {
                DataContext dc = new JdbcDataContext(con);
                Schema schema = dc.getDefaultSchema();
                Table productsTable = schema.getTableByName("PRODUCTS");
-               Relationship[] relationships = productsTable.getRelationships();
-               Relationship relationship = relationships[0];
+               Relationship relationship = 
productsTable.getRelationships().iterator().next();
                assertEquals(
                                
"Relationship[primaryTable=PRODUCTS,primaryColumns=[PRODUCTCODE],foreignTable=ORDERFACT,foreignColumns=[PRODUCTCODE]]",
                                relationship.toString());
@@ -153,9 +152,9 @@ public class QuerySplitterTest extends JdbcTestCase {
                Query sq = new Query().from(employeesTable, 
"e").from(customersTable,
                                "c");
                SelectItem empSelectItem = new SelectItem(
-                               employeesTable.getColumns()[0]);
+                               employeesTable.getColumns().get(0));
                SelectItem custSelectItem = new SelectItem(
-                               customersTable.getColumns()[0]);
+                               customersTable.getColumns().get(0));
                sq.select(empSelectItem, custSelectItem);
                assertEquals(
                                "SELECT e._EMPLOYEENUMBER_, c._CUSTOMERNUMBER_ 
FROM PUBLIC._EMPLOYEES_ e, PUBLIC._CUSTOMERS_ c",

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/SqliteTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/SqliteTest.java 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/SqliteTest.java
index 3a8d1a4..6e4b417 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/SqliteTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/SqliteTest.java
@@ -97,14 +97,13 @@ public class SqliteTest extends TestCase {
 
     public void testGetSchemas() throws Exception {
         DataContext dc = new JdbcDataContext(_connection);
-        String[] schemaNames = dc.getSchemaNames();
+        String[] schemaNames = dc.getSchemaNames().toArray(new 
String[dc.getSchemaNames().size()]);
         assertEquals("[null]", Arrays.toString(schemaNames));
 
         Schema schema = dc.getDefaultSchema();
         assertNotNull(schema);
         assertNull(schema.getName());
 
-        Table[] tables = schema.getTables();
         assertEquals("[Table[name=system,type=TABLE,remarks=null], "
                 + "Table[name=permission,type=TABLE,remarks=null], "
                 + "Table[name=auth_cookie,type=TABLE,remarks=null], " + 
"Table[name=session,type=TABLE,remarks=null], "
@@ -115,11 +114,11 @@ public class SqliteTest extends TestCase {
                 + "Table[name=ticket_custom,type=TABLE,remarks=null], " + 
"Table[name=enum,type=TABLE,remarks=null], "
                 + "Table[name=component,type=TABLE,remarks=null], " + 
"Table[name=milestone,type=TABLE,remarks=null], "
                 + "Table[name=version,type=TABLE,remarks=null], " + 
"Table[name=report,type=TABLE,remarks=null]]",
-                Arrays.toString(tables));
+                Arrays.toString(schema.getTables().toArray()));
 
         // Index- and key-info is not yet implemented in the JDBC driver
 
-        assertEquals("[]", Arrays.toString(schema.getRelationships()));
+        assertEquals("[]", 
Arrays.toString(schema.getRelationships().toArray()));
 
         Table wikiTable = schema.getTableByName("WIKI");
         assertEquals(
@@ -131,13 +130,13 @@ public class SqliteTest extends TestCase {
                         + 
"Column[name=text,columnNumber=5,type=VARCHAR,nullable=true,nativeType=TEXT,columnSize=2000000000],
 "
                         + 
"Column[name=comment,columnNumber=6,type=VARCHAR,nullable=true,nativeType=TEXT,columnSize=2000000000],
 "
                         + 
"Column[name=readonly,columnNumber=7,type=INTEGER,nullable=true,nativeType=INTEGER,columnSize=2000000000]]",
-                Arrays.toString(wikiTable.getColumns()));
+                Arrays.toString(wikiTable.getColumns().toArray()));
 
         Table permissionTable = schema.getTableByName("PERMISSION");
         assertEquals(
                 
"[Column[name=username,columnNumber=0,type=VARCHAR,nullable=true,nativeType=TEXT,columnSize=2000000000],
 "
                         + 
"Column[name=action,columnNumber=1,type=VARCHAR,nullable=true,nativeType=TEXT,columnSize=2000000000]]",
-                Arrays.toString(permissionTable.getColumns()));
+                Arrays.toString(permissionTable.getColumns().toArray()));
     }
 
     public void testExecuteQuery() throws Exception {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/DB2Test.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/DB2Test.java 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/DB2Test.java
index aef6f51..f4a7df7 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/DB2Test.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/DB2Test.java
@@ -85,8 +85,7 @@ public class DB2Test extends AbstractJdbIntegrationTest {
         }
         JdbcDataContext dc = new JdbcDataContext(getConnection());
         Schema schema = dc.getDefaultSchema();
-        String[] tableNames = schema.getTableNames();
-        System.out.println("Tables: " + Arrays.toString(tableNames));
+        System.out.println("Tables: " + 
Arrays.toString(schema.getTableNames().toArray()));
 
         Table countryTable = schema.getTableByName("COUNTRY");
         assertNotNull(countryTable);
@@ -110,8 +109,7 @@ public class DB2Test extends AbstractJdbIntegrationTest {
         }
         JdbcDataContext dc = new JdbcDataContext(getConnection());
         Schema schema = dc.getDefaultSchema();
-        String[] tableNames = schema.getTableNames();
-        System.out.println("Tables: " + Arrays.toString(tableNames));
+        System.out.println("Tables: " + 
Arrays.toString(schema.getTableNames().toArray()));
 
         Table countryTable = schema.getTableByName("COUNTRY");
         assertNotNull(countryTable);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/FirebirdTest.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/FirebirdTest.java
 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/FirebirdTest.java
index f883e83..9857ea5 100644
--- 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/FirebirdTest.java
+++ 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/FirebirdTest.java
@@ -21,9 +21,13 @@ package org.apache.metamodel.jdbc.integrationtests;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.Set;
+import java.util.stream.Collectors;
 
+import javax.management.relation.Relation;
 import javax.swing.table.TableModel;
 
+import com.google.common.collect.Sets;
 import org.apache.metamodel.data.DataSet;
 import org.apache.metamodel.data.DataSetTableModel;
 import org.apache.metamodel.jdbc.JdbcDataContext;
@@ -56,7 +60,7 @@ public class FirebirdTest extends AbstractJdbIntegrationTest {
                return;
            }
                JdbcDataContext dataContext = getDataContext();
-        Schema[] schemas = dataContext.getSchemas();
+        Schema[] schemas = dataContext.getSchemas().toArray(new 
Schema[dataContext.getSchemas().size()]);
                assertEquals(1, schemas.length);
                Schema schema = dataContext.getDefaultSchema();
                
assertEquals("{JdbcTable[name=COUNTRY,type=TABLE,remarks=<null>],"
@@ -69,26 +73,28 @@ public class FirebirdTest extends 
AbstractJdbIntegrationTest {
                                + 
"JdbcTable[name=PROJECT,type=TABLE,remarks=<null>],"
                                + 
"JdbcTable[name=PROJ_DEPT_BUDGET,type=TABLE,remarks=<null>],"
                                + 
"JdbcTable[name=SALARY_HISTORY,type=TABLE,remarks=<null>],"
-                               + 
"JdbcTable[name=SALES,type=TABLE,remarks=<null>]}", 
Arrays.toString(schema.getTables()));
-
-               assertEquals(
-                               
"{Relationship[primaryTable=COUNTRY,primaryColumns={COUNTRY},foreignTable=CUSTOMER,foreignColumns={COUNTRY}],"
-                                               + 
"Relationship[primaryTable=COUNTRY,primaryColumns={COUNTRY},foreignTable=JOB,foreignColumns={JOB_COUNTRY}],"
-                                               + 
"Relationship[primaryTable=CUSTOMER,primaryColumns={CUST_NO},foreignTable=SALES,foreignColumns={CUST_NO}],"
-                                               + 
"Relationship[primaryTable=DEPARTMENT,primaryColumns={DEPT_NO},foreignTable=DEPARTMENT,foreignColumns={HEAD_DEPT}],"
-                                               + 
"Relationship[primaryTable=DEPARTMENT,primaryColumns={DEPT_NO},foreignTable=EMPLOYEE,foreignColumns={DEPT_NO}],"
-                                               + 
"Relationship[primaryTable=DEPARTMENT,primaryColumns={DEPT_NO},foreignTable=PROJ_DEPT_BUDGET,foreignColumns={DEPT_NO}],"
-                                               + 
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=DEPARTMENT,foreignColumns={MNGR_NO}],"
-                                               + 
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=EMPLOYEE_PROJECT,foreignColumns={EMP_NO}],"
-                                               + 
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=PROJECT,foreignColumns={TEAM_LEADER}],"
-                                               + 
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=SALARY_HISTORY,foreignColumns={EMP_NO}],"
-                                               + 
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=SALES,foreignColumns={SALES_REP}],"
-                                               + 
"Relationship[primaryTable=JOB,primaryColumns={JOB_CODE},foreignTable=EMPLOYEE,foreignColumns={JOB_CODE}],"
-                                               + 
"Relationship[primaryTable=JOB,primaryColumns={JOB_GRADE},foreignTable=EMPLOYEE,foreignColumns={JOB_GRADE}],"
-                                               + 
"Relationship[primaryTable=JOB,primaryColumns={JOB_COUNTRY},foreignTable=EMPLOYEE,foreignColumns={JOB_COUNTRY}],"
-                                               + 
"Relationship[primaryTable=PROJECT,primaryColumns={PROJ_ID},foreignTable=EMPLOYEE_PROJECT,foreignColumns={PROJ_ID}],"
-                                               + 
"Relationship[primaryTable=PROJECT,primaryColumns={PROJ_ID},foreignTable=PROJ_DEPT_BUDGET,foreignColumns={PROJ_ID}]}",
-                               Arrays.toString(schema.getRelationships()));
+                               + 
"JdbcTable[name=SALES,type=TABLE,remarks=<null>]}", 
Arrays.toString(schema.getTables().toArray()));
+               
+               Set<String> relationStrings = 
schema.getRelationships().stream().map(rel -> 
rel.toString()).collect(Collectors.toSet());
+               Set<String> referenceRelationStrings = Sets.newHashSet(
+                               
"Relationship[primaryTable=COUNTRY,primaryColumns={COUNTRY},foreignTable=CUSTOMER,foreignColumns={COUNTRY}]",
+                                               
"Relationship[primaryTable=COUNTRY,primaryColumns={COUNTRY},foreignTable=JOB,foreignColumns={JOB_COUNTRY}]",
+                                               
"Relationship[primaryTable=CUSTOMER,primaryColumns={CUST_NO},foreignTable=SALES,foreignColumns={CUST_NO}]",
+                                               
"Relationship[primaryTable=DEPARTMENT,primaryColumns={DEPT_NO},foreignTable=DEPARTMENT,foreignColumns={HEAD_DEPT}]",
+                                               
"Relationship[primaryTable=DEPARTMENT,primaryColumns={DEPT_NO},foreignTable=EMPLOYEE,foreignColumns={DEPT_NO}]",
+                                               
"Relationship[primaryTable=DEPARTMENT,primaryColumns={DEPT_NO},foreignTable=PROJ_DEPT_BUDGET,foreignColumns={DEPT_NO}]",
+                                               
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=DEPARTMENT,foreignColumns={MNGR_NO}]",
+                                               
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=EMPLOYEE_PROJECT,foreignColumns={EMP_NO}]",
+                                               
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=PROJECT,foreignColumns={TEAM_LEADER}]",
+                                               
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=SALARY_HISTORY,foreignColumns={EMP_NO}]",
+                                               
"Relationship[primaryTable=EMPLOYEE,primaryColumns={EMP_NO},foreignTable=SALES,foreignColumns={SALES_REP}]",
+                                               
"Relationship[primaryTable=JOB,primaryColumns={JOB_CODE},foreignTable=EMPLOYEE,foreignColumns={JOB_CODE}]",
+                                               
"Relationship[primaryTable=JOB,primaryColumns={JOB_GRADE},foreignTable=EMPLOYEE,foreignColumns={JOB_GRADE}]",
+                                               
"Relationship[primaryTable=JOB,primaryColumns={JOB_COUNTRY},foreignTable=EMPLOYEE,foreignColumns={JOB_COUNTRY}]",
+                                               
"Relationship[primaryTable=PROJECT,primaryColumns={PROJ_ID},foreignTable=EMPLOYEE_PROJECT,foreignColumns={PROJ_ID}]",
+                                               
"Relationship[primaryTable=PROJECT,primaryColumns={PROJ_ID},foreignTable=PROJ_DEPT_BUDGET,foreignColumns={PROJ_ID}]"
+               );
+               assertEquals(relationStrings,referenceRelationStrings);
        }
 
        public void testExecuteQuery() throws Exception {
@@ -99,9 +105,9 @@ public class FirebirdTest extends AbstractJdbIntegrationTest 
{
         Schema schema = dataContext.getDefaultSchema();
                Table departmentTable = schema.getTableByName("DEPARTMENT");
                Table employeeTable = schema.getTableByName("EMPLOYEE");
-               Query q = new Query().from(new FromItem(JoinType.INNER, 
departmentTable.getRelationships(employeeTable)[0]));
-               q.select(departmentTable.getColumns()[1]);
-               q.select(new 
SelectItem(employeeTable.getColumns()[4]).setAlias("hire-date"));
+               Query q = new Query().from(new FromItem(JoinType.INNER, 
departmentTable.getRelationships(employeeTable).iterator().next()));
+               q.select(departmentTable.getColumns().get(1));
+               q.select(new 
SelectItem(employeeTable.getColumns().get(4)).setAlias("hire-date"));
                assertEquals(
                                "SELECT \"DEPARTMENT\".\"DEPARTMENT\", 
\"EMPLOYEE\".\"HIRE_DATE\" AS hire-date FROM \"EMPLOYEE\" INNER JOIN 
\"DEPARTMENT\" ON \"EMPLOYEE\".\"EMP_NO\" = \"DEPARTMENT\".\"MNGR_NO\"",
                                q.toString());

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
index c5485ca..dc93a28 100644
--- 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
+++ 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
@@ -227,17 +227,17 @@ public class MysqlTest extends AbstractJdbIntegrationTest 
{
         Table actorTable = schema.getTableByName("actor");
         assertEquals(
                 
"[Column[name=actor_id,columnNumber=0,type=SMALLINT,nullable=false,nativeType=SMALLINT
 UNSIGNED,columnSize=5], 
Column[name=first_name,columnNumber=1,type=VARCHAR,nullable=false,nativeType=VARCHAR,columnSize=45],
 
Column[name=last_name,columnNumber=2,type=VARCHAR,nullable=false,nativeType=VARCHAR,columnSize=45],
 
Column[name=last_update,columnNumber=3,type=TIMESTAMP,nullable=false,nativeType=TIMESTAMP,columnSize=19]]",
-                Arrays.toString(actorTable.getColumns()));
+                Arrays.toString(actorTable.getColumns().toArray()));
         Table filmTable = schema.getTableByName("film");
         assertEquals(
                 
"[Column[name=film_id,columnNumber=0,type=SMALLINT,nullable=false,nativeType=SMALLINT
 UNSIGNED,columnSize=5], 
Column[name=title,columnNumber=1,type=VARCHAR,nullable=false,nativeType=VARCHAR,columnSize=255],
 
Column[name=description,columnNumber=2,type=LONGVARCHAR,nullable=true,nativeType=TEXT,columnSize=65535],
 
Column[name=release_year,columnNumber=3,type=DATE,nullable=true,nativeType=YEAR,columnSize=0],
 
Column[name=language_id,columnNumber=4,type=TINYINT,nullable=false,nativeType=TINYINT
 UNSIGNED,columnSize=3], 
Column[name=original_language_id,columnNumber=5,type=TINYINT,nullable=true,nativeType=TINYINT
 UNSIGNED,columnSize=3], 
Column[name=rental_duration,columnNumber=6,type=TINYINT,nullable=false,nativeType=TINYINT
 UNSIGNED,columnSize=3], 
Column[name=rental_rate,columnNumber=7,type=DECIMAL,nullable=false,nativeType=DECIMAL,columnSize=4],
 
Column[name=length,columnNumber=8,type=SMALLINT,nullable=true,nativeType=SMALLINT
 UNSIGNED,columnSize=5], Column[name=replacement_c
 
ost,columnNumber=9,type=DECIMAL,nullable=false,nativeType=DECIMAL,columnSize=5],
 
Column[name=rating,columnNumber=10,type=CHAR,nullable=true,nativeType=ENUM,columnSize=5],
 
Column[name=special_features,columnNumber=11,type=CHAR,nullable=true,nativeType=SET,columnSize=54],
 
Column[name=last_update,columnNumber=12,type=TIMESTAMP,nullable=false,nativeType=TIMESTAMP,columnSize=19]]",
-                Arrays.toString(filmTable.getColumns()));
+                Arrays.toString(filmTable.getColumns().toArray()));
         Table filmActorJoinTable = schema.getTableByName("film_actor");
         assertEquals(
                 
"[Column[name=actor_id,columnNumber=0,type=SMALLINT,nullable=false,nativeType=SMALLINT
 UNSIGNED,columnSize=5], "
                         + 
"Column[name=film_id,columnNumber=1,type=SMALLINT,nullable=false,nativeType=SMALLINT
 UNSIGNED,columnSize=5], "
                         + 
"Column[name=last_update,columnNumber=2,type=TIMESTAMP,nullable=false,nativeType=TIMESTAMP,columnSize=19]]",
-                Arrays.toString(filmActorJoinTable.getColumns()));
+                Arrays.toString(filmActorJoinTable.getColumns().toArray()));
 
         Query q = new Query();
         q.from(new FromItem(actorTable).setAlias("a"));
@@ -314,7 +314,7 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
                 + "Table[name=nicer_but_slower_film_list,type=VIEW,remarks=], "
                 + "Table[name=sales_by_film_category,type=VIEW,remarks=], "
                 + "Table[name=sales_by_store,type=VIEW,remarks=], " + 
"Table[name=staff_list,type=VIEW,remarks=]]",
-                Arrays.toString(schema.getTables()));
+                Arrays.toString(schema.getTables().toArray()));
 
         Table filmTable = schema.getTableByName("film");
         assertEquals(
@@ -331,10 +331,10 @@ public class MysqlTest extends AbstractJdbIntegrationTest 
{
                         + 
"Column[name=rating,columnNumber=10,type=CHAR,nullable=true,nativeType=ENUM,columnSize=5],
 "
                         + 
"Column[name=special_features,columnNumber=11,type=CHAR,nullable=true,nativeType=SET,columnSize=54],
 "
                         + 
"Column[name=last_update,columnNumber=12,type=TIMESTAMP,nullable=false,nativeType=TIMESTAMP,columnSize=19]]",
-                Arrays.toString(filmTable.getColumns()));
+                Arrays.toString(filmTable.getColumns().toArray()));
         assertEquals(
                 
"[Relationship[primaryTable=language,primaryColumns=[language_id],foreignTable=film,foreignColumns=[language_id]],
 
Relationship[primaryTable=language,primaryColumns=[language_id],foreignTable=film,foreignColumns=[original_language_id]],
 
Relationship[primaryTable=film,primaryColumns=[film_id],foreignTable=film_actor,foreignColumns=[film_id]],
 
Relationship[primaryTable=film,primaryColumns=[film_id],foreignTable=film_category,foreignColumns=[film_id]],
 
Relationship[primaryTable=film,primaryColumns=[film_id],foreignTable=inventory,foreignColumns=[film_id]]]",
-                Arrays.toString(filmTable.getRelationships()));
+                Arrays.toString(filmTable.getRelationships().toArray()));
 
         assertEquals("[Table[name=actor,type=TABLE,remarks=], " + 
"Table[name=address,type=TABLE,remarks=], "
                 + "Table[name=category,type=TABLE,remarks=], " + 
"Table[name=city,type=TABLE,remarks=], "
@@ -349,7 +349,7 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
                 + "Table[name=nicer_but_slower_film_list,type=VIEW,remarks=], "
                 + "Table[name=sales_by_film_category,type=VIEW,remarks=], "
                 + "Table[name=sales_by_store,type=VIEW,remarks=], " + 
"Table[name=staff_list,type=VIEW,remarks=]]",
-                Arrays.toString(schema.getTables()));
+                Arrays.toString(schema.getTables().toArray()));
 
         Table staffView = schema.getTableByName("staff_list");
         assertEquals(
@@ -361,7 +361,7 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
                         + 
"Column[name=city,columnNumber=5,type=VARCHAR,nullable=false,nativeType=VARCHAR,columnSize=50],
 "
                         + 
"Column[name=country,columnNumber=6,type=VARCHAR,nullable=false,nativeType=VARCHAR,columnSize=50],
 "
                         + 
"Column[name=SID,columnNumber=7,type=TINYINT,nullable=false,nativeType=TINYINT 
UNSIGNED,columnSize=3]]",
-                Arrays.toString(staffView.getColumns()));
+                Arrays.toString(staffView.getColumns().toArray()));
     }
 
     public void testSplitQuery() throws Exception {
@@ -377,7 +377,7 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
         assertNotNull(paymentTable);
         Column countryColumn = staffListTable.getColumnByName("country");
         assertNotNull(countryColumn);
-        Column paymentColumn = paymentTable.getColumns()[0];
+        Column paymentColumn = paymentTable.getColumns().get(0);
         assertNotNull(paymentColumn);
         Query q = new Query().from(staffListTable, "sl").from(paymentTable, 
"e").select(countryColumn, paymentColumn);
         assertEquals("SELECT sl.`country`, e.`payment_id` FROM 
sakila.`staff_list` sl, sakila.`payment` e",

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/OracleTest.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/OracleTest.java 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/OracleTest.java
index 6924362..826bc81 100644
--- 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/OracleTest.java
+++ 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/OracleTest.java
@@ -21,10 +21,16 @@ package org.apache.metamodel.jdbc.integrationtests;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 import javax.swing.table.TableModel;
+import javax.swing.text.html.Option;
 
+import com.google.common.collect.Sets;
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.data.DataSet;
 import org.apache.metamodel.data.DataSetTableModel;
@@ -126,7 +132,7 @@ public class OracleTest extends AbstractJdbIntegrationTest {
             return;
         }
         DataContext dc = new JdbcDataContext(getConnection());
-        String[] schemaNames = dc.getSchemaNames();
+        String[] schemaNames = dc.getSchemaNames().toArray(new 
String[dc.getSchemas().size()]);
 
         String concatSchemas = Arrays.toString(schemaNames);
 
@@ -198,16 +204,19 @@ public class OracleTest extends 
AbstractJdbIntegrationTest {
                 + ",JdbcTable[name=JOB_HISTORY,type=TABLE,remarks=<null>]"
                 + ",JdbcTable[name=LOCATIONS,type=TABLE,remarks=<null>]"
                 + ",JdbcTable[name=REGIONS,type=TABLE,remarks=<null>]"
-                + 
",JdbcTable[name=EMP_DETAILS_VIEW,type=VIEW,remarks=<null>]}", 
Arrays.toString(schema.getTables()));
+                + 
",JdbcTable[name=EMP_DETAILS_VIEW,type=VIEW,remarks=<null>]}", 
Arrays.toString(schema.getTables().toArray()));
 
-        Relationship[] employeeRelationships = 
schema.getTableByName("EMPLOYEES").getRelationships();
-        assertEquals(
-                
"{Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=DEPARTMENTS,foreignColumns={MANAGER_ID}],"
-                        + 
"Relationship[primaryTable=DEPARTMENTS,primaryColumns={DEPARTMENT_ID},foreignTable=EMPLOYEES,foreignColumns={DEPARTMENT_ID}],"
-                        + 
"Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=EMPLOYEES,foreignColumns={MANAGER_ID}],"
-                        + 
"Relationship[primaryTable=JOBS,primaryColumns={JOB_ID},foreignTable=EMPLOYEES,foreignColumns={JOB_ID}],"
-                        + 
"Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=JOB_HISTORY,foreignColumns={EMPLOYEE_ID}]}",
-                Arrays.toString(employeeRelationships));
+        Collection<Relationship> employeeRelationships = 
schema.getTableByName("EMPLOYEES").getRelationships();
+
+        Set<String> employeeRelStrings = 
employeeRelationships.stream().map(rel -> 
rel.toString()).collect(Collectors.toSet());
+
+        assertEquals(Sets.newHashSet(
+                
"Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=DEPARTMENTS,foreignColumns={MANAGER_ID}]",
+                        
"Relationship[primaryTable=DEPARTMENTS,primaryColumns={DEPARTMENT_ID},foreignTable=EMPLOYEES,foreignColumns={DEPARTMENT_ID}]",
+                        
"Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=EMPLOYEES,foreignColumns={MANAGER_ID}]",
+                        
"Relationship[primaryTable=JOBS,primaryColumns={JOB_ID},foreignTable=EMPLOYEES,foreignColumns={JOB_ID}]",
+                        
"Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=JOB_HISTORY,foreignColumns={EMPLOYEE_ID}]"),
+                employeeRelStrings);
 
         assertEquals(
                 
"{JdbcColumn[name=EMPLOYEE_ID,columnNumber=0,type=DECIMAL,nullable=false,nativeType=NUMBER,columnSize=6],"
@@ -221,14 +230,14 @@ public class OracleTest extends 
AbstractJdbIntegrationTest {
                         + 
"JdbcColumn[name=COMMISSION_PCT,columnNumber=8,type=DECIMAL,nullable=true,nativeType=NUMBER,columnSize=2],"
                         + 
"JdbcColumn[name=MANAGER_ID,columnNumber=9,type=DECIMAL,nullable=true,nativeType=NUMBER,columnSize=6],"
                         + 
"JdbcColumn[name=DEPARTMENT_ID,columnNumber=10,type=DECIMAL,nullable=true,nativeType=NUMBER,columnSize=4]}",
-                
Arrays.toString(schema.getTableByName("EMPLOYEES").getColumns()));
+                
Arrays.toString(schema.getTableByName("EMPLOYEES").getColumns().toArray()));
 
         assertEquals(
                 
"{JdbcColumn[name=DEPARTMENT_ID,columnNumber=0,type=DECIMAL,nullable=false,nativeType=NUMBER,columnSize=4],"
                         + 
"JdbcColumn[name=DEPARTMENT_NAME,columnNumber=1,type=VARCHAR,nullable=false,nativeType=VARCHAR2,columnSize=30],"
                         + 
"JdbcColumn[name=MANAGER_ID,columnNumber=2,type=DECIMAL,nullable=true,nativeType=NUMBER,columnSize=6],"
                         + 
"JdbcColumn[name=LOCATION_ID,columnNumber=3,type=DECIMAL,nullable=true,nativeType=NUMBER,columnSize=4]}",
-                
Arrays.toString(schema.getTableByName("DEPARTMENTS").getColumns()));
+                
Arrays.toString(schema.getTableByName("DEPARTMENTS").getColumns().toArray()));
     }
 
     public void testExecuteQuery() throws Exception {
@@ -238,12 +247,12 @@ public class OracleTest extends 
AbstractJdbIntegrationTest {
         Schema schema = getDataContext().getSchemaByName("HR");
         Table employeeTable = schema.getTableByName("EMPLOYEES");
         Table departmentsTable = schema.getTableByName("DEPARTMENTS");
-        Relationship relationship = 
employeeTable.getRelationships(departmentsTable)[0];
-        assertEquals(
-                
"Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=DEPARTMENTS,foreignColumns={MANAGER_ID}]",
-                relationship.toString());
+        Optional<Relationship> relationship = 
employeeTable.getRelationships(departmentsTable).stream()
+                .filter(rel-> 
rel.toString().equals("Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=DEPARTMENTS,foreignColumns={MANAGER_ID}]"))
+                .findFirst();
+        assertTrue(relationship.isPresent());
 
-        Query q = new Query().from(new FromItem(JoinType.INNER, 
relationship)).select(
+        Query q = new Query().from(new FromItem(JoinType.INNER, 
relationship.get())).select(
                 employeeTable.getColumnByName("EMAIL"), 
departmentsTable.getColumnByName("DEPARTMENT_NAME"));
         q.getSelectClause().getItem(0).setAlias("e-mail");
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
index 6f8fb09..a34be81 100644
--- 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
+++ 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/PostgresqlTest.java
@@ -21,11 +21,7 @@ package org.apache.metamodel.jdbc.integrationtests;
 import java.lang.reflect.Method;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Optional;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 import javax.swing.table.TableModel;
@@ -455,15 +451,15 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
         try {
             DataSet ds = 
dc.query().from("my_table").select("some_double").execute();
             assertTrue(ds.next());
-            Double minVal = (Double) 
ds.getRow().getValue(ds.getSelectItems()[0]);
+            Double minVal = (Double) 
ds.getRow().getValue(ds.getSelectItems().get(0));
             assertTrue(ds.next());
-            Double maxVal = (Double) 
ds.getRow().getValue(ds.getSelectItems()[0]);
+            Double maxVal = (Double) 
ds.getRow().getValue(ds.getSelectItems().get(0));
             assertTrue(ds.next());
-            Double negInf = (Double) 
ds.getRow().getValue(ds.getSelectItems()[0]);
+            Double negInf = (Double) 
ds.getRow().getValue(ds.getSelectItems().get(0));
             assertTrue(ds.next());
-            Double posInf = (Double) 
ds.getRow().getValue(ds.getSelectItems()[0]);
+            Double posInf = (Double) 
ds.getRow().getValue(ds.getSelectItems().get(0));
             assertTrue(ds.next());
-            Double nAn = (Double) ds.getRow().getValue(ds.getSelectItems()[0]);
+            Double nAn = (Double) 
ds.getRow().getValue(ds.getSelectItems().get(0));
             assertFalse(ds.next());
 
             assertEquals(Double.MIN_VALUE, minVal, DELTA);
@@ -604,7 +600,7 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                     Table table = cb.createTable(schema, 
"my_table").withColumn("id").ofType(ColumnType.INTEGER)
                             
.ofNativeType("SERIAL").nullable(false).withColumn("person 
name").ofSize(255).withColumn(
                                     
"age").ofType(ColumnType.INTEGER).execute();
-                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames()));
+                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames().toArray()));
                     assertEquals(
                             
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
                             table.getColumnByName("id").toString());
@@ -670,7 +666,7 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                     Table table = cb.createTable(schema, 
"my_table").withColumn("id").ofType(ColumnType.INTEGER)
                             
.ofNativeType("SERIAL").nullable(false).withColumn("person 
name").ofSize(255).withColumn(
                                     
"age").ofType(ColumnType.INTEGER).execute();
-                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames()));
+                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames().toArray()));
                     assertEquals(
                             
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
                             table.getColumnByName("id").toString());
@@ -723,7 +719,7 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                     Table table = cb.createTable(schema, 
"my_table").withColumn("id").ofType(ColumnType.INTEGER)
                             
.ofNativeType("SERIAL").nullable(false).withColumn("person 
name").ofSize(255).withColumn(
                                     
"age").ofType(ColumnType.INTEGER).execute();
-                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames()));
+                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames().toArray()));
                     assertEquals(
                             
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
                             table.getColumnByName("id").toString());
@@ -781,8 +777,8 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
         }
 
         DataContext dc = new JdbcDataContext(getConnection());
-        Schema[] schemas = dc.getSchemas();
-        assertTrue(schemas.length >= 3);
+        List<Schema> schemas = dc.getSchemas();
+        assertTrue(schemas.size() >= 3);
 
         assertNotNull(dc.getSchemaByName("information_schema"));
         assertNotNull(dc.getSchemaByName("pg_catalog"));
@@ -794,7 +790,7 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                 + "Table[name=cust_hist,type=TABLE,remarks=null], " + 
"Table[name=customers,type=TABLE,remarks=null], "
                 + "Table[name=inventory,type=TABLE,remarks=null], " + 
"Table[name=orderlines,type=TABLE,remarks=null], "
                 + "Table[name=orders,type=TABLE,remarks=null], " + 
"Table[name=products,type=TABLE,remarks=null], "
-                + "Table[name=reorder,type=TABLE,remarks=null]]", 
Arrays.toString(schema.getTables()));
+                + "Table[name=reorder,type=TABLE,remarks=null]]", 
Arrays.toString(schema.getTables().toArray()));
 
         Table productsTable = schema.getTableByName("products");
         assertEquals(
@@ -805,7 +801,7 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                         + 
"Column[name=price,columnNumber=4,type=NUMERIC,nullable=false,nativeType=numeric,columnSize=12],
 "
                         + 
"Column[name=special,columnNumber=5,type=SMALLINT,nullable=true,nativeType=int2,columnSize=5],
 "
                         + 
"Column[name=common_prod_id,columnNumber=6,type=INTEGER,nullable=false,nativeType=int4,columnSize=10]]",
-                Arrays.toString(productsTable.getColumns()));
+                Arrays.toString(productsTable.getColumns().toArray()));
         Table customersTable = schema.getTableByName("customers");
         assertEquals(
                 
"[Column[name=customerid,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10],
 "
@@ -828,17 +824,19 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                         + 
"Column[name=age,columnNumber=17,type=SMALLINT,nullable=true,nativeType=int2,columnSize=5],
 "
                         + 
"Column[name=income,columnNumber=18,type=INTEGER,nullable=true,nativeType=int4,columnSize=10],
 "
                         + 
"Column[name=gender,columnNumber=19,type=VARCHAR,nullable=true,nativeType=varchar,columnSize=1]]",
-                Arrays.toString(customersTable.getColumns()));
-        Relationship[] relations = customersTable.getRelationships();
-        assertEquals(2, relations.length);
+                Arrays.toString(customersTable.getColumns().toArray()));
+        List<Relationship> relations = new 
ArrayList<>(customersTable.getRelationships());
+        // bit o a hack to ensure ordering
+        Collections.sort(relations, (rel1,rel2) -> 
rel1.getForeignTable().getName().compareTo(rel2.getForeignTable().getName()));
+        assertEquals(2, relations.size());
         assertEquals(
                 
"[Relationship[primaryTable=customers,primaryColumns=[customerid],foreignTable=cust_hist,foreignColumns=[customerid]],
 "
                         + 
"Relationship[primaryTable=customers,primaryColumns=[customerid],foreignTable=orders,foreignColumns=[customerid]]]",
-                Arrays.toString(relations));
-        assertEquals("Table[name=customers,type=TABLE,remarks=null]", 
relations[0].getPrimaryTable().toString());
-        assertEquals("Table[name=cust_hist,type=TABLE,remarks=null]", 
relations[0].getForeignTable().toString());
-        assertEquals("Table[name=customers,type=TABLE,remarks=null]", 
relations[1].getPrimaryTable().toString());
-        assertEquals("Table[name=orders,type=TABLE,remarks=null]", 
relations[1].getForeignTable().toString());
+                Arrays.toString(relations.toArray()));
+        assertEquals("Table[name=customers,type=TABLE,remarks=null]", 
relations.get(0).getPrimaryTable().toString());
+        assertEquals("Table[name=cust_hist,type=TABLE,remarks=null]", 
relations.get(0).getForeignTable().toString());
+        assertEquals("Table[name=customers,type=TABLE,remarks=null]", 
relations.get(1).getPrimaryTable().toString());
+        assertEquals("Table[name=orders,type=TABLE,remarks=null]", 
relations.get(1).getForeignTable().toString());
 
         Table ordersTable = schema.getTableByName("orderlines");
         assertEquals(
@@ -847,7 +845,7 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                         + 
"Column[name=prod_id,columnNumber=2,type=INTEGER,nullable=false,nativeType=int4,columnSize=10],
 "
                         + 
"Column[name=quantity,columnNumber=3,type=SMALLINT,nullable=false,nativeType=int2,columnSize=5],
 "
                         + 
"Column[name=orderdate,columnNumber=4,type=DATE,nullable=false,nativeType=date,columnSize=13]]",
-                Arrays.toString(ordersTable.getColumns()));
+                Arrays.toString(ordersTable.getColumns().toArray()));
     }
 
     public void testExecuteQueryInPublicSchema() throws Exception {
@@ -945,7 +943,7 @@ public class PostgresqlTest extends 
AbstractJdbIntegrationTest {
                     Table table = cb.createTable(schema, 
"my_table").withColumn("id").ofType(ColumnType.INTEGER)
                             
.ofNativeType("SERIAL").nullable(false).withColumn("person 
name").ofSize(255).withColumn(
                                     
"age").ofType(ColumnType.INTEGER).execute();
-                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames()));
+                    assertEquals("[id, person name, age]", 
Arrays.toString(table.getColumnNames().toArray()));
                     assertEquals(
                             
"Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=serial,columnSize=10]",
                             table.getColumnByName("id").toString());

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerJtdsDriverTest.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerJtdsDriverTest.java
 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerJtdsDriverTest.java
index c72d2f3..9926b64 100644
--- 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerJtdsDriverTest.java
+++ 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerJtdsDriverTest.java
@@ -161,7 +161,7 @@ public class SQLServerJtdsDriverTest extends 
AbstractJdbIntegrationTest {
         // the jdbc driver represents the date as a VARCHAR
         
assertEquals("[Column[name=id,columnNumber=0,type=INTEGER,nullable=false,nativeType=int,columnSize=10],
 "
                 + 
"Column[name=birthdate,columnNumber=1,type=VARCHAR,nullable=true,nativeType=date,columnSize=10]]",
-                Arrays.toString(table.getColumns()));
+                Arrays.toString(table.getColumns().toArray()));
 
         DataSet ds = 
dc.query().from(table).select("id").and("birthdate").execute();
         assertTrue(ds.next());
@@ -184,7 +184,7 @@ public class SQLServerJtdsDriverTest extends 
AbstractJdbIntegrationTest {
                 TableType.VIEW }, DATABASE_NAME);
         Query q = new 
Query().select("Name").from("Production.Product").where("COlor IS NOT 
NULL").setMaxRows(5);
         DataSet dataSet = strategy.executeQuery(q);
-        assertEquals("[Name]", Arrays.toString(dataSet.getSelectItems()));
+        assertEquals("[Name]", 
Arrays.toString(dataSet.getSelectItems().toArray()));
         assertTrue(dataSet.next());
         assertEquals("Row[values=[LL Crankarm]]", dataSet.getRow().toString());
         assertTrue(dataSet.next());
@@ -200,7 +200,7 @@ public class SQLServerJtdsDriverTest extends 
AbstractJdbIntegrationTest {
         }
         JdbcDataContext dc = new JdbcDataContext(getConnection(), new 
TableType[] { TableType.TABLE, TableType.VIEW },
                 DATABASE_NAME);
-        Schema[] schemas = dc.getSchemas();
+        Schema[] schemas = dc.getSchemas().toArray(new 
Schema[dc.getSchemas().size()]);
 
         assertEquals(8, schemas.length);
         assertEquals("Schema[name=HumanResources]", schemas[0].toString());
@@ -228,7 +228,7 @@ public class SQLServerJtdsDriverTest extends 
AbstractJdbIntegrationTest {
         assertEquals("dbo", schema.getName());
 
         assertEquals("[Sales, HumanResources, dbo, Purchasing, sys, 
Production, INFORMATION_SCHEMA, Person]",
-                Arrays.toString(strategy.getSchemaNames()));
+                Arrays.toString(strategy.getSchemaNames().toArray()));
     }
 
     public void testQueryRewriterQuoteAliases() throws Exception {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerMicrosoftDriverTest.java
----------------------------------------------------------------------
diff --git 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerMicrosoftDriverTest.java
 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerMicrosoftDriverTest.java
index 2fcd0ff..f297622 100644
--- 
a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerMicrosoftDriverTest.java
+++ 
b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/SQLServerMicrosoftDriverTest.java
@@ -56,7 +56,7 @@ public class SQLServerMicrosoftDriverTest extends 
AbstractJdbIntegrationTest {
                 new TableType[] { TableType.TABLE, TableType.VIEW }, 
DATABASE_NAME);
         Query q = new 
Query().select("Name").from("Production.Product").where("COlor IS NOT 
NULL").setMaxRows(5);
         DataSet dataSet = strategy.executeQuery(q);
-        assertEquals("[Name]", Arrays.toString(dataSet.getSelectItems()));
+        assertEquals("[Name]", 
Arrays.toString(dataSet.getSelectItems().toArray()));
         assertTrue(dataSet.next());
         assertEquals("Row[values=[LL Crankarm]]", dataSet.getRow().toString());
         assertTrue(dataSet.next());
@@ -73,7 +73,7 @@ public class SQLServerMicrosoftDriverTest extends 
AbstractJdbIntegrationTest {
         
         JdbcDataContext dc = new JdbcDataContext(getConnection(), new 
TableType[] { TableType.TABLE, TableType.VIEW },
                 DATABASE_NAME);
-        Schema[] schemas = dc.getSchemas();
+        Schema[] schemas = dc.getSchemas().toArray(new 
Schema[dc.getSchemas().size()]);
 
         assertEquals(8, schemas.length);
         assertEquals("Schema[name=HumanResources]", schemas[0].toString());
@@ -100,7 +100,7 @@ public class SQLServerMicrosoftDriverTest extends 
AbstractJdbIntegrationTest {
                 TableType.GLOBAL_TEMPORARY }, DATABASE_NAME);
 
         assertEquals("[Sales, HumanResources, dbo, Purchasing, sys, 
Production, INFORMATION_SCHEMA, Person]",
-                Arrays.toString(strategy.getSchemaNames()));
+                Arrays.toString(strategy.getSchemaNames().toArray()));
 
         assertEquals("Schema[name=dbo]", 
strategy.getDefaultSchema().toString());
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/json/src/main/java/org/apache/metamodel/json/JsonDataContext.java
----------------------------------------------------------------------
diff --git a/json/src/main/java/org/apache/metamodel/json/JsonDataContext.java 
b/json/src/main/java/org/apache/metamodel/json/JsonDataContext.java
index 90f726d..6578d7c 100644
--- a/json/src/main/java/org/apache/metamodel/json/JsonDataContext.java
+++ b/json/src/main/java/org/apache/metamodel/json/JsonDataContext.java
@@ -20,6 +20,8 @@ package org.apache.metamodel.json;
 
 import java.io.File;
 import java.io.InputStream;
+import java.util.List;
+import java.util.stream.Collectors;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.MetaModelException;
@@ -85,9 +87,9 @@ public class JsonDataContext extends 
QueryPostprocessDataContext implements Docu
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int maxRows) {
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int maxRows) {
         final DocumentConverter documentConverter = 
_schemaBuilder.getDocumentConverter(table);
-        final SelectItem[] selectItems = 
MetaModelHelper.createSelectItems(columns);
+        final List<SelectItem> selectItems = 
columns.stream().map(SelectItem::new).collect(Collectors.toList());
         final DataSetHeader header = new CachingDataSetHeader(selectItems);
         final DocumentSource documentSource = 
getDocumentSourceForTable(table.getName());
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/json/src/test/java/org/apache/metamodel/json/JsonDataContextTest.java
----------------------------------------------------------------------
diff --git 
a/json/src/test/java/org/apache/metamodel/json/JsonDataContextTest.java 
b/json/src/test/java/org/apache/metamodel/json/JsonDataContextTest.java
index 0dba661..bfc1283 100644
--- a/json/src/test/java/org/apache/metamodel/json/JsonDataContextTest.java
+++ b/json/src/test/java/org/apache/metamodel/json/JsonDataContextTest.java
@@ -55,7 +55,7 @@ public class JsonDataContextTest extends TestCase {
         final Table table = dc.getDefaultSchema().getTable(0);
         assertEquals("tbl", table.getName());
 
-        assertEquals("[cl]", Arrays.toString(table.getColumnNames()));
+        assertEquals("[cl]", 
Arrays.toString(table.getColumnNames().toArray()));
 
         final DataSet dataSet = dc.query().from("tbl").select("cl").execute();
         assertTrue(dataSet.next());
@@ -68,10 +68,9 @@ public class JsonDataContextTest extends TestCase {
 
     private void runParseabilityTest(JsonDataContext dc) {
         final Table table = dc.getDefaultSchema().getTable(0);
-        assertEquals("[country, gender, id, name]", 
Arrays.toString(table.getColumnNames()));
-        final Column[] columns = table.getColumns();
+        assertEquals("[country, gender, id, name]", 
Arrays.toString(table.getColumnNames().toArray()));
 
-        final DataSet dataSet = dc.materializeMainSchemaTable(table, columns, 
100000);
+        final DataSet dataSet = dc.materializeMainSchemaTable(table, 
table.getColumns(), 100000);
         assertTrue(dataSet.next());
         assertEquals("Row[values=[US, null, 1234, John Doe]]", 
dataSet.getRow().toString());
         assertTrue(dataSet.next());
@@ -105,7 +104,7 @@ public class JsonDataContextTest extends TestCase {
         final JsonDataContext dataContext = new JsonDataContext(resource);
 
         final Schema schema = dataContext.getDefaultSchema();
-        assertEquals("[nested_fields.json]", 
Arrays.toString(schema.getTableNames()));
+        assertEquals("[nested_fields.json]", 
Arrays.toString(schema.getTableNames().toArray()));
 
         final DataSet ds = dataContext.query().from(schema.getTable(0))
                 .select(FunctionType.MAP_VALUE, "name", new Object[] { "first" 
}).execute();
@@ -125,7 +124,7 @@ public class JsonDataContextTest extends TestCase {
         final JsonDataContext dataContext = new JsonDataContext(resource);
 
         final Schema schema = dataContext.getDefaultSchema();
-        assertEquals("[nested_fields.json]", 
Arrays.toString(schema.getTableNames()));
+        assertEquals("[nested_fields.json]", 
Arrays.toString(schema.getTableNames().toArray()));
 
         final DataSet ds = 
dataContext.query().from(schema.getTable(0)).select("name.first").execute();
         try {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
 
b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
index 84ae8db..d5d0432 100644
--- 
a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
+++ 
b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
@@ -26,6 +26,7 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.MetaModelException;
@@ -200,8 +201,7 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
             for (SimpleTableDef tableDef : _tableDefs) {
 
                 MutableTable table = tableDef.toTable().setSchema(schema);
-                Column[] rowIdColumns = 
table.getColumnsOfType(ColumnType.ROWID);
-                for (Column column : rowIdColumns) {
+                for (Column column : table.getColumnsOfType(ColumnType.ROWID)) 
{
                     if (column instanceof MutableColumn) {
                         ((MutableColumn) column).setPrimaryKey(true);
                     }
@@ -286,10 +286,7 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
                     logger.debug("Query can be expressed in full MongoDB, no 
post processing needed.");
 
                     // prepare for a non-post-processed query
-                    Column[] columns = new Column[selectItems.size()];
-                    for (int i = 0; i < columns.length; i++) {
-                        columns[i] = selectItems.get(i).getColumn();
-                    }
+
 
                     // checking if the query is a primary key lookup query
                     if (whereItems.size() == 1) {
@@ -324,16 +321,15 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
                     }
 
                     if (thereIsAtLeastOneAlias) {
-                        final SelectItem[] selectItemsAsArray = 
selectItems.toArray(new SelectItem[selectItems.size()]);
                         final DataSet dataSet = 
materializeMainSchemaTableInternal(
                                 table,
-                                selectItemsAsArray,
+                                selectItems,
                                 whereItems,
                                 firstRow,
                                 maxRows, false);
                         return dataSet;
                     } else {
-                        final DataSet dataSet = 
materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                        final DataSet dataSet = 
materializeMainSchemaTableInternal(table, selectItems, whereItems, firstRow,
                                 maxRows, false);
                         return dataSet;
                     }
@@ -345,14 +341,9 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
         return super.executeQuery(query);
     }
 
-    private DataSet materializeMainSchemaTableInternal(Table table, Column[] 
columns, List<FilterItem> whereItems,
-            int firstRow, int maxRows, boolean queryPostProcessed) {
-        DBCursor cursor = getCursor(table, whereItems, firstRow, maxRows);
 
-        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
-    }
 
-    private DataSet materializeMainSchemaTableInternal(Table table, 
SelectItem[] selectItems,
+    private DataSet materializeMainSchemaTableInternal(Table table, 
List<SelectItem> selectItems,
             List<FilterItem> whereItems, int firstRow, int maxRows, boolean 
queryPostProcessed) {
         DBCursor cursor = getCursor(table, whereItems, firstRow, maxRows);
 
@@ -478,13 +469,25 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int maxRows) {
-        return materializeMainSchemaTableInternal(table, columns, null, 1, 
maxRows, true);
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int maxRows) {
+        return materializeMainSchemaTableInternal(
+                table,
+                
columns.stream().map(SelectItem::new).collect(Collectors.toList()),
+                null,
+                1,
+                maxRows,
+                true);
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int firstRow, int maxRows) {
-        return materializeMainSchemaTableInternal(table, columns, null, 
firstRow, maxRows, true);
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int firstRow, int maxRows) {
+        return materializeMainSchemaTableInternal(
+                table,
+                
columns.stream().map(SelectItem::new).collect(Collectors.toList()),
+                null,
+                firstRow,
+                maxRows,
+                true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
 
b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
index ea7cd9e..3197945 100644
--- 
a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
+++ 
b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
@@ -29,6 +29,8 @@ import org.slf4j.LoggerFactory;
 import com.mongodb.DBCursor;
 import com.mongodb.DBObject;
 
+import java.util.List;
+
 final class MongoDbDataSet extends AbstractDataSet {
 
     private static final Logger logger = 
LoggerFactory.getLogger(MongoDbDataSet.class);
@@ -39,14 +41,9 @@ final class MongoDbDataSet extends AbstractDataSet {
     private boolean _closed;
     private volatile DBObject _dbObject;
 
-    public MongoDbDataSet(DBCursor cursor, Column[] columns, boolean 
queryPostProcessed) {
-        super(columns);
-        _cursor = cursor;
-        _queryPostProcessed = queryPostProcessed;
-        _closed = false;
-    }
 
-    public MongoDbDataSet(DBCursor cursor, SelectItem[] selectItems, boolean 
queryPostProcessed) {
+
+    public MongoDbDataSet(DBCursor cursor, List<SelectItem> selectItems, 
boolean queryPostProcessed) {
         super(selectItems);
         _cursor = cursor;
         _queryPostProcessed = queryPostProcessed;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
 
b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
index da99955..398c408 100644
--- 
a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
+++ 
b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
@@ -280,7 +280,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
 
         
assertTrue(Arrays.asList(dataContext.getDefaultSchema().getTableNames()).contains(getCollectionName()));
         Table table = 
dataContext.getDefaultSchema().getTableByName(getCollectionName());
-        assertEquals("[_id, baz, foo, id, list, name]", 
Arrays.toString(table.getColumnNames()));
+        assertEquals("[_id, baz, foo, id, list, name]", 
Arrays.toString(table.getColumnNames().toArray()));
 
         assertEquals(ColumnType.MAP, table.getColumnByName("baz").getType());
         assertEquals(ColumnType.STRING, 
table.getColumnByName("foo").getType());
@@ -460,7 +460,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         // do a query that we cannot push to mongo
         // Replace column index 0 by 1
         ds = dataContext.query().from(getCollectionName())
-                .select(FunctionType.SUM, 
dataContext.getDefaultSchema().getTables()[0].getColumnByName("id"))
+                .select(FunctionType.SUM, 
dataContext.getDefaultSchema().getTables().get(0).getColumnByName("id"))
                 .where("foo").isEquals("bar").execute();
         assertEquals(InMemoryDataSet.class, ds.getClass());
 
@@ -478,8 +478,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         dc.executeUpdate(new UpdateScript() {
             @Override
             public void run(UpdateCallback callback) {
-                Table[] tables = defaultSchema.getTables();
-                for (Table table : tables) {
+                for (Table table : defaultSchema.getTables()) {
                     callback.deleteFrom(table).execute();
                 }
             }
@@ -514,8 +513,8 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         dataSet = dc.query().from("some_entries").selectCount().execute();
         dataSet.close();
         assertTrue(dataSet.next());
-        assertEquals(1, dataSet.getSelectItems().length);
-        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems()[0]);
+        assertEquals(1, dataSet.getSelectItems().size());
+        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems().get(0));
         assertEquals(4l, 
dataSet.getRow().getValue(SelectItem.getCountAllItem()));
         assertFalse(dataSet.next());
         assertEquals(InMemoryDataSet.class, dataSet.getClass());
@@ -524,8 +523,8 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         dataSet = 
dc.query().from("some_entries").selectCount().where("foo").greaterThan(2).execute();
         dataSet.close();
         assertTrue(dataSet.next());
-        assertEquals(1, dataSet.getSelectItems().length);
-        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems()[0]);
+        assertEquals(1, dataSet.getSelectItems().size());
+        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems().get(0));
         assertEquals(2l, 
dataSet.getRow().getValue(SelectItem.getCountAllItem()));
         assertFalse(dataSet.next());
         assertEquals(InMemoryDataSet.class, dataSet.getClass());
@@ -657,7 +656,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
                 "addresses[5].foobar" }));
 
         final DataSet ds1 = dc.executeQuery("select gender AS my_gender, 
name.first AS my_name from my_collection where gender LIKE '%MALE%'");
-        final SelectItem[] selectItems = ds1.getSelectItems();
+        final SelectItem[] selectItems = ds1.getSelectItems().toArray(new 
SelectItem[ds1.getSelectItems().size()]);
         SelectItem firstSelectItem = selectItems[0];
         SelectItem secondSelectItem = selectItems[1];
         try {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
 
b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
index b0aa9dc..becda44 100644
--- 
a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
+++ 
b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataCopyer.java
@@ -21,6 +21,7 @@ package org.apache.metamodel.mongodb.mongo2;
 import java.io.File;
 import java.sql.Connection;
 import java.sql.DriverManager;
+import java.util.List;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.UpdateCallback;
@@ -95,7 +96,7 @@ public class MongoDbDataCopyer {
                 final Table sourceTable = getSourceTable();
                 final Table targetTable = 
callback.createTable(targetDataContext.getDefaultSchema(), _collectionName)
                         .like(sourceTable).execute();
-                final Column[] sourceColumns = sourceTable.getColumns();
+                final List<Column> sourceColumns = sourceTable.getColumns();
                 final DataSet dataSet = 
_sourceDataContext.query().from(sourceTable).select(sourceColumns).execute();
                 while (dataSet.next()) {
                     final Row row = dataSet.getRow();

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
 
b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
index ddb18d5..9bdec81 100644
--- 
a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
+++ 
b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
@@ -27,6 +27,7 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.MetaModelException;
@@ -200,7 +201,7 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
             for (SimpleTableDef tableDef : _tableDefs) {
 
                 MutableTable table = tableDef.toTable().setSchema(schema);
-                Column[] rowIdColumns = 
table.getColumnsOfType(ColumnType.ROWID);
+                List<Column> rowIdColumns = 
table.getColumnsOfType(ColumnType.ROWID);
                 for (Column column : rowIdColumns) {
                     if (column instanceof MutableColumn) {
                         ((MutableColumn) column).setPrimaryKey(true);
@@ -286,10 +287,7 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
                     logger.debug("Query can be expressed in full MongoDB, no 
post processing needed.");
 
                     // prepare for a non-post-processed query
-                    Column[] columns = new Column[selectItems.size()];
-                    for (int i = 0; i < columns.length; i++) {
-                        columns[i] = selectItems.get(i).getColumn();
-                    }
+
 
                     // checking if the query is a primary key lookup query
                     if (whereItems.size() == 1) {
@@ -325,16 +323,15 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
                     }
 
                     if (thereIsAtLeastOneAlias) {
-                        final SelectItem[] selectItemsAsArray = 
selectItems.toArray(new SelectItem[selectItems.size()]);
                         final DataSet dataSet = 
materializeMainSchemaTableInternal(
                                 table,
-                                selectItemsAsArray,
+                                selectItems,
                                 whereItems,
                                 firstRow,
                                 maxRows, false);
                         return dataSet;
                     } else {
-                        final DataSet dataSet = 
materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                        final DataSet dataSet = 
materializeMainSchemaTableInternal(table, selectItems, whereItems, firstRow,
                                 maxRows, false);
                         return dataSet;
                     }
@@ -346,14 +343,8 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
         return super.executeQuery(query);
     }
 
-    private DataSet materializeMainSchemaTableInternal(Table table, Column[] 
columns, List<FilterItem> whereItems,
-            int firstRow, int maxRows, boolean queryPostProcessed) {
-        MongoCursor<Document> cursor = getDocumentMongoCursor(table, 
whereItems, firstRow, maxRows);
-
-        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
-    }
 
-    private DataSet materializeMainSchemaTableInternal(Table table, 
SelectItem[] selectItems, List<FilterItem> whereItems,
+    private DataSet materializeMainSchemaTableInternal(Table table, 
List<SelectItem> selectItems, List<FilterItem> whereItems,
             int firstRow, int maxRows, boolean queryPostProcessed) {
         MongoCursor<Document> cursor = getDocumentMongoCursor(table, 
whereItems, firstRow, maxRows);
 
@@ -507,13 +498,26 @@ public class MongoDbDataContext extends 
QueryPostprocessDataContext implements U
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int maxRows) {
-        return materializeMainSchemaTableInternal(table, columns, null, 1, 
maxRows, true);
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int maxRows) {
+
+        return materializeMainSchemaTableInternal(
+                table,
+                
columns.stream().map(SelectItem::new).collect(Collectors.toList()),
+                null,
+                1,
+                maxRows,
+                true);
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int firstRow, int maxRows) {
-        return materializeMainSchemaTableInternal(table, columns, null, 
firstRow, maxRows, true);
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int firstRow, int maxRows) {
+        return materializeMainSchemaTableInternal(
+                table,
+                
columns.stream().map(SelectItem::new).collect(Collectors.toList()),
+                null,
+                firstRow,
+                maxRows,
+                true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
 
b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
index 19e543f..76a7636 100644
--- 
a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
+++ 
b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
@@ -29,6 +29,8 @@ import org.slf4j.LoggerFactory;
 
 import com.mongodb.client.MongoCursor;
 
+import java.util.List;
+
 final class MongoDbDataSet extends AbstractDataSet {
 
     private static final Logger logger = 
LoggerFactory.getLogger(MongoDbDataSet.class);
@@ -39,14 +41,8 @@ final class MongoDbDataSet extends AbstractDataSet {
     private boolean _closed;
     private volatile Document _document;
 
-    public MongoDbDataSet(MongoCursor<Document> cursor, Column[] columns, 
boolean queryPostProcessed) {
-        super(columns);
-        _cursor = cursor;
-        _queryPostProcessed = queryPostProcessed;
-        _closed = false;
-    }
 
-    public MongoDbDataSet(MongoCursor<Document> cursor, SelectItem[] 
selectItems, boolean queryPostProcessed) {
+    public MongoDbDataSet(MongoCursor<Document> cursor, List<SelectItem> 
selectItems, boolean queryPostProcessed) {
         super(selectItems);
         _cursor = cursor;
         _queryPostProcessed = queryPostProcessed;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
 
b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
index 197fae9..9751719 100644
--- 
a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
+++ 
b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
@@ -265,7 +265,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         
assertTrue(Arrays.asList(dataContext.getDefaultSchema().getTableNames()).contains(getCollectionName()));
         
         Table table = 
dataContext.getDefaultSchema().getTableByName(getCollectionName());
-        assertEquals("[_id, baz, foo, id, list, name]", 
Arrays.toString(table.getColumnNames()));
+        assertEquals("[_id, baz, foo, id, list, name]", 
Arrays.toString(table.getColumnNames().toArray()));
 
         assertEquals(ColumnType.MAP, table.getColumnByName("baz").getType());
         assertEquals(ColumnType.STRING, 
table.getColumnByName("foo").getType());
@@ -445,7 +445,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         // do a query that we cannot push to mongo
         // Replace column index 0 by 1
         ds = dataContext.query().from(getCollectionName())
-                .select(FunctionType.SUM, 
dataContext.getDefaultSchema().getTables()[0].getColumnByName("id"))
+                .select(FunctionType.SUM, 
dataContext.getDefaultSchema().getTables().get(0).getColumnByName("id"))
                 .where("foo").isEquals("bar").execute();
         assertEquals(InMemoryDataSet.class, ds.getClass());
 
@@ -463,8 +463,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         dc.executeUpdate(new UpdateScript() {
             @Override
             public void run(UpdateCallback callback) {
-                Table[] tables = defaultSchema.getTables();
-                for (Table table : tables) {
+                for (Table table : defaultSchema.getTables()) {
                     callback.deleteFrom(table).execute();
                 }
             }
@@ -499,8 +498,8 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         dataSet = dc.query().from("some_entries").selectCount().execute();
         dataSet.close();
         assertTrue(dataSet.next());
-        assertEquals(1, dataSet.getSelectItems().length);
-        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems()[0]);
+        assertEquals(1, dataSet.getSelectItems().size());
+        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems().get(0));
         assertEquals(4l, 
dataSet.getRow().getValue(SelectItem.getCountAllItem()));
         assertFalse(dataSet.next());
         assertEquals(InMemoryDataSet.class, dataSet.getClass());
@@ -509,8 +508,8 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
         dataSet = 
dc.query().from("some_entries").selectCount().where("foo").greaterThan(2).execute();
         dataSet.close();
         assertTrue(dataSet.next());
-        assertEquals(1, dataSet.getSelectItems().length);
-        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems()[0]);
+        assertEquals(1, dataSet.getSelectItems().size());
+        assertEquals(SelectItem.getCountAllItem(), 
dataSet.getSelectItems().get(0));
         assertEquals(2l, 
dataSet.getRow().getValue(SelectItem.getCountAllItem()));
         assertFalse(dataSet.next());
         assertEquals(InMemoryDataSet.class, dataSet.getClass());
@@ -633,7 +632,7 @@ public class MongoDbDataContextTest extends MongoDbTestCase 
{
                         "addresses[5].foobar" }));
 
         final DataSet ds1 = dc.executeQuery("select gender as my_gender, 
name.first as my_name from my_collection where gender LIKE '%MALE%'");
-        final SelectItem[] selectItems = ds1.getSelectItems();
+        final SelectItem[] selectItems = ds1.getSelectItems().toArray(new 
SelectItem[ds1.getSelectItems().size()]);
         SelectItem firstSelectItem = selectItems[0];
         SelectItem secondSelectItem = selectItems[1];
         try {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
----------------------------------------------------------------------
diff --git 
a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
 
b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
index 42ef536..351d6ee 100644
--- 
a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
+++ 
b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataCopyer.java
@@ -98,7 +98,7 @@ public class MongoDbDataCopyer {
                 final Table sourceTable = getSourceTable();
                 final Table targetTable = 
callback.createTable(targetDataContext.getDefaultSchema(), _collectionName)
                         .like(sourceTable).execute();
-                final Column[] sourceColumns = sourceTable.getColumns();
+                final Column[] sourceColumns = 
sourceTable.getColumns().toArray(new Column[sourceTable.getColumns().size()]);
                 final DataSet dataSet = 
_sourceDataContext.query().from(sourceTable).select(sourceColumns).execute();
                 while (dataSet.next()) {
                     final Row row = dataSet.getRow();

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jCypherQueryBuilder.java
----------------------------------------------------------------------
diff --git 
a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jCypherQueryBuilder.java 
b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jCypherQueryBuilder.java
index 5d3ac6c..38079ce 100644
--- 
a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jCypherQueryBuilder.java
+++ 
b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jCypherQueryBuilder.java
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import org.apache.metamodel.query.FilterItem;
 import org.apache.metamodel.schema.Column;
@@ -29,15 +30,14 @@ import org.apache.metamodel.schema.Table;
 
 public class Neo4jCypherQueryBuilder {
 
-    public static String buildSelectQuery(Table table, Column[] columns, int 
firstRow, int maxRows) {
-        String[] columnNames = new String[columns.length];
-        for (int i = 0; i < columns.length; i++) {
-            columnNames[i] = columns[i].getName();
-        }
+    public static String buildSelectQuery(Table table, List<Column> columns, 
int firstRow, int maxRows) {
+        List<String> columnNames = columns.stream()
+                .map(col -> col.getName())
+                .collect(Collectors.toList());
         return buildSelectQuery(table.getName(), columnNames, firstRow, 
maxRows);
     }
 
-    public static String buildSelectQuery(String tableName, String[] 
columnNames, int firstRow, int maxRows) {
+    public static String buildSelectQuery(String tableName, List<String> 
columnNames, int firstRow, int maxRows) {
         Map<String, String> returnClauseMap = new LinkedHashMap<>();
         Map<String, Integer> relationshipIndexMap = new LinkedHashMap<>();
         for (String columnName : columnNames) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
----------------------------------------------------------------------
diff --git 
a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java 
b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
index cb0b2ac..82f710d 100644
--- a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
+++ b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataContext.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import org.apache.http.HttpHost;
 import org.apache.http.client.methods.HttpGet;
@@ -296,14 +297,14 @@ public class Neo4jDataContext extends 
QueryPostprocessDataContext implements Dat
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int firstRow, int maxRows) {
-        if ((columns != null) && (columns.length > 0)) {
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int firstRow, int maxRows) {
+        if ((columns != null) && (columns.size() > 0)) {
             Neo4jDataSet dataSet = null;
             try {
                 String selectQuery = 
Neo4jCypherQueryBuilder.buildSelectQuery(table, columns, firstRow, maxRows);
                 String responseJSONString = 
_requestWrapper.executeCypherQuery(selectQuery);
                 JSONObject resultJSONObject = new 
JSONObject(responseJSONString);
-                final SelectItem[] selectItems = 
MetaModelHelper.createSelectItems(columns);
+                final List<SelectItem> selectItems = 
columns.stream().map(SelectItem::new).collect(Collectors.toList());
                 dataSet = new Neo4jDataSet(selectItems, resultJSONObject);
             } catch (JSONException e) {
                 logger.error("Error occured in parsing JSON while 
materializing the schema: ", e);
@@ -318,7 +319,7 @@ public class Neo4jDataContext extends 
QueryPostprocessDataContext implements Dat
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int maxRows) {
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int maxRows) {
         return materializeMainSchemaTable(table, columns, 1, maxRows);
     }
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataSet.java
----------------------------------------------------------------------
diff --git a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataSet.java 
b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataSet.java
index bf132e8..537a068 100644
--- a/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataSet.java
+++ b/neo4j/src/main/java/org/apache/metamodel/neo4j/Neo4jDataSet.java
@@ -27,13 +27,15 @@ import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import java.util.List;
+
 final class Neo4jDataSet extends AbstractDataSet {
 
     private JSONObject _resultJSONObject;
     private int _currentRowIndex;
     private Row _row;
 
-    public Neo4jDataSet(SelectItem[] selectItems, JSONObject resultJSONObject) 
{
+    public Neo4jDataSet(List<SelectItem> selectItems, JSONObject 
resultJSONObject) {
         super(selectItems);
         _resultJSONObject = resultJSONObject;
         _currentRowIndex = 0;

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
----------------------------------------------------------------------
diff --git 
a/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java 
b/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
index 1246ce2..89bf977 100644
--- a/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
+++ b/neo4j/src/test/java/org/apache/metamodel/neo4j/Neo4jDataContextTest.java
@@ -78,13 +78,13 @@ public class Neo4jDataContextTest extends Neo4jTestCase {
 
         // Do not check the precise count, Neo4j keeps labels forever, there 
are
         // probably many more than you imagine...
-        List<String> tableNames = Arrays.asList(schema.getTableNames());
+        List<String> tableNames = schema.getTableNames();
         logger.info("Tables (labels) detected: " + tableNames);
         assertTrue(tableNames.contains("JUnitLabel"));
         assertFalse(tableNames.contains("JUnitLabelTemp"));
 
         Table table = schema.getTableByName("JUnitLabel");
-        List<String> columnNames = Arrays.asList(table.getColumnNames());
+        List<String> columnNames = table.getColumnNames();
         assertTrue(columnNames.contains("property1"));
         assertTrue(columnNames.contains("property2"));
     }
@@ -122,18 +122,18 @@ public class Neo4jDataContextTest extends Neo4jTestCase {
 
         // Do not check the precise count, Neo4j keeps labels forever, there 
are
         // probably many more than you imagine...
-        List<String> tableNames = Arrays.asList(schema.getTableNames());
+        List<String> tableNames = schema.getTableNames();
         logger.info("Tables (labels) detected: " + tableNames);
         assertTrue(tableNames.contains("JUnitPerson"));
         assertTrue(tableNames.contains("JUnitBook"));
 
         Table tablePerson = schema.getTableByName("JUnitPerson");
-        List<String> personColumnNames = 
Arrays.asList(tablePerson.getColumnNames());
+        List<String> personColumnNames = tablePerson.getColumnNames();
         assertEquals("[_id, name, age, rel_HAS_READ, rel_HAS_READ#rating, 
rel_HAS_BROWSED]",
                 personColumnNames.toString());
 
         Table tableBook = schema.getTableByName("JUnitBook");
-        List<String> bookColumnNames = 
Arrays.asList(tableBook.getColumnNames());
+        List<String> bookColumnNames = tableBook.getColumnNames();
         assertEquals("[_id, title]", bookColumnNames.toString());
     }
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/openoffice/src/main/java/org/apache/metamodel/openoffice/OpenOfficeDataContext.java
----------------------------------------------------------------------
diff --git 
a/openoffice/src/main/java/org/apache/metamodel/openoffice/OpenOfficeDataContext.java
 
b/openoffice/src/main/java/org/apache/metamodel/openoffice/OpenOfficeDataContext.java
index 25275a5..7df2350 100644
--- 
a/openoffice/src/main/java/org/apache/metamodel/openoffice/OpenOfficeDataContext.java
+++ 
b/openoffice/src/main/java/org/apache/metamodel/openoffice/OpenOfficeDataContext.java
@@ -26,6 +26,7 @@ import java.io.OutputStream;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
@@ -114,7 +115,7 @@ public class OpenOfficeDataContext extends 
AbstractDataContext {
        }
 
        @Override
-       protected String[] getSchemaNamesInternal() {
+       protected List<String> getSchemaNamesInternal() {
                return _dataContextDelegate.getSchemaNames();
        }
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/openoffice/src/test/java/org/apache/metamodel/openoffice/OpenOfficeDataContextTest.java
----------------------------------------------------------------------
diff --git 
a/openoffice/src/test/java/org/apache/metamodel/openoffice/OpenOfficeDataContextTest.java
 
b/openoffice/src/test/java/org/apache/metamodel/openoffice/OpenOfficeDataContextTest.java
index 78015d2..0ac3462 100644
--- 
a/openoffice/src/test/java/org/apache/metamodel/openoffice/OpenOfficeDataContextTest.java
+++ 
b/openoffice/src/test/java/org/apache/metamodel/openoffice/OpenOfficeDataContextTest.java
@@ -57,7 +57,7 @@ public class OpenOfficeDataContextTest extends TestCase {
 
        public void testGetSchemas() throws Exception {
                assertEquals("[INFORMATION_SCHEMA, PUBLIC]",
-                               Arrays.toString(_dataContext.getSchemaNames()));
+                               
Arrays.toString(_dataContext.getSchemaNames().toArray()));
 
                Schema informationSchema = _dataContext
                                .getSchemaByName("INFORMATION_SCHEMA");
@@ -68,10 +68,10 @@ public class OpenOfficeDataContextTest extends TestCase {
 
                assertEquals(
                                
"[Table[name=CONTRIBUTORS,type=TABLE,remarks=null], 
Table[name=projects,type=TABLE,remarks=null]]",
-                               Arrays.toString(schema.getTables()));
+                               Arrays.toString(schema.getTables().toArray()));
                assertEquals(
                                
"[Relationship[primaryTable=CONTRIBUTORS,primaryColumns=[ID],foreignTable=projects,foreignColumns=[admin]]]",
-                               Arrays.toString(schema.getRelationships()));
+                               
Arrays.toString(schema.getRelationships().toArray()));
        }
 
        public void testQueryUppercaseTable() throws Exception {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
----------------------------------------------------------------------
diff --git a/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java 
b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
index 9369e96..f694202 100644
--- a/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
+++ b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.MetaModelException;
@@ -103,13 +104,13 @@ public class PojoDataContext extends 
QueryPostprocessDataContext implements Upda
     }
 
     @Override
-    protected DataSet materializeMainSchemaTable(Table table, Column[] 
columns, int maxRows) {
+    protected DataSet materializeMainSchemaTable(Table table, List<Column> 
columns, int maxRows) {
         final TableDataProvider<?> pojoTable = _tables.get(table.getName());
         if (pojoTable == null) {
             throw new IllegalArgumentException("No such POJO table: " + 
table.getName());
         }
 
-        final SelectItem[] selectItems = 
MetaModelHelper.createSelectItems(columns);
+        final List<SelectItem> selectItems = 
columns.stream().map(SelectItem::new).collect(Collectors.toList());
 
         @SuppressWarnings({ "rawtypes", "unchecked" })
         DataSet dataSet = new PojoDataSet(pojoTable, selectItems);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2d156bcd/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataSet.java
----------------------------------------------------------------------
diff --git a/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataSet.java 
b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataSet.java
index 1c86ef1..952d85c 100644
--- a/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataSet.java
+++ b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataSet.java
@@ -19,6 +19,7 @@
 package org.apache.metamodel.pojo;
 
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.metamodel.data.AbstractDataSet;
 import org.apache.metamodel.data.DataSet;
@@ -38,7 +39,7 @@ final class PojoDataSet<E> extends AbstractDataSet {
     private final Iterator<E> _iterator;
     private E _next;
 
-    public PojoDataSet(TableDataProvider<E> pojoTable, SelectItem[] 
selectItems) {
+    public PojoDataSet(TableDataProvider<E> pojoTable, List<SelectItem> 
selectItems) {
         super(selectItems);
         _pojoTable = pojoTable;
 

Reply via email to