Author: bcarothers
Date: 2009-12-20 20:22:00 -0500 (Sun, 20 Dec 2009)
New Revision: 1467
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/SqlServerMetadataCollector.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/create.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/drop.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/create.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/drop.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/create.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/drop.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mysql5/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mysql5/drop.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/create.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/drop.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/create.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/drop.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/create.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/drop.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/create.ddl
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/drop.ddl
Removed:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/
trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/jdbc/
Modified:
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml
trunk/extensions/dna-connector-jdbc-metadata/pom.xml
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataCollector.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataException.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataConnectorTest.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/database.properties
trunk/pom.xml
Log:
DNA-37
Applied patch that adds DDL and code corrections for other databases (Oracle 10g/11g, MS
SQL 2008, IBM DB2 v9, Sybase ASE 15).
Modified:
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml
===================================================================
---
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/docs/reference/src/main/docbook/en-US/content/connectors/jdbc_metadata.xml 2009-12-21
01:22:00 UTC (rev 1467)
@@ -1,39 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ JBoss DNA (
http://www.jboss.org/dna)
- ~
- ~ See the COPYRIGHT.txt file distributed with this work for information
- ~ regarding copyright ownership. Some portions may be licensed
- ~ to Red Hat, Inc. under one or more contributor license agreements.
- ~ See the AUTHORS.txt file in the distribution for a full listing of
- ~ individual contributors.
- ~
- ~ JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- ~ is licensed to you under the terms of the GNU Lesser General Public License as
- ~ published by the Free Software Foundation; either version 2.1 of
- ~ the License, or (at your option) any later version.
- ~
- ~ JBoss DNA is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
+ <!--
+ ~ JBoss DNA (
http://www.jboss.org/dna) ~ ~ See the COPYRIGHT.txt file
+ distributed with this work for information ~ regarding copyright
+ ownership. Some portions may be licensed ~ to Red Hat, Inc. under one
+ or more contributor license agreements. ~ See the AUTHORS.txt file in
+ the distribution for a full listing of ~ individual contributors. ~ ~
+ JBoss DNA is free software. Unless otherwise indicated, all code in
+ JBoss DNA ~ is licensed to you under the terms of the GNU Lesser
+ General Public License as ~ published by the Free Software Foundation;
+ either version 2.1 of ~ the License, or (at your option) any later
+ version. ~ ~ JBoss DNA is distributed in the hope that it will be
+ useful, ~ but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License ~ for more details. ~ ~ You should have
+ received a copy of the GNU Lesser General Public License ~ along with
+ this distribution; if not, write to: ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor ~ Boston, MA 02110-1301 USA
+ -->
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % CustomDTD SYSTEM "../../custom.dtd">
%CustomDTD;
]>
<chapter id="jdbc-metadata-connector">
- <title>JDBC Metadata Connector</title>
- <para>
- This connector provides read-only access to the metadata (e.g., catalogs, schemas,
table structures) of a relational database.
- The connector yields a content graph that looks like this:
-<programlisting>
+ <title>JDBC Metadata Connector</title>
+ <para>
+ This connector provides read-only access to the metadata (e.g.,
+ catalogs, schemas, table structures) of a relational database.
+ The
+ connector yields a content graph that looks like this:
+ <programlisting>
/ (root node)
+ <catalog name> - one node for each accessible catalog in the
database.
+ <schema name> - one node for each accessible schema in the
catalog.
@@ -49,10 +44,12 @@
will be used instead when determining the graph name.
<note>
<para>
- This connector has currently been tested successfully against MySQL 5 (with the InnoDB
engine), PostgreSQL 8, and HSQLDB.
+ This connector has currently been tested successfully against Oracle 10g, Oracle 11g,
Microsoft SQL Server 2008 (with the Microsoft JDBC driver),
+ IBM DB2 v9, Sybase ASE 15, MySQL 5 (with the InnoDB engine), PostgreSQL 8, and
HSQLDB.
As JDBC driver implementations of the &DatabaseMetaData; interface tend to vary
widely, other databases may or may not work
- with the default &MetadataCollector; implementation. We are, of course,
interested in correcting any database-specific issues
- that arise, but the <code>metadataCollectorClassName</code> property
provides a mechanism to support immediate workarounds.
+ with the default &MetadataCollector; implementation. As one example, the
<code>metadataCollectorClassName</code> property
+ must be set to
<code>org.jboss.dna.connector.meta.jdbc.SqlServerMetadataConnector</code> if
the Microsoft JDBC driver is used. This is
+ to work around a known bug where that driver returns a list of users from a call to
&DatabaseMetaData;.getSchemas() instead of a list of schemas.
</para>
</note>
</para>
Modified: trunk/extensions/dna-connector-jdbc-metadata/pom.xml
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/pom.xml 2009-12-19 17:24:18 UTC (rev
1466)
+++ trunk/extensions/dna-connector-jdbc-metadata/pom.xml 2009-12-21 01:22:00 UTC (rev
1467)
@@ -42,7 +42,13 @@
<groupId>org.jboss.dna</groupId>
<artifactId>dna-graph</artifactId>
</dependency>
- <dependency>
+ <dependency>
+ <groupId>com.sybase</groupId>
+ <artifactId>jconnect</artifactId>
+ <version>6.0.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-graph</artifactId>
<version>${project.version}</version>
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataCollector.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataCollector.java 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataCollector.java 2009-12-21
01:22:00 UTC (rev 1467)
@@ -26,9 +26,13 @@
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
+import net.jcip.annotations.Immutable;
/**
* Default {@link MetadataCollector} implementation that uses the {@link DatabaseMetaData
built-in JDBC support} for collecting
@@ -36,7 +40,8 @@
*
* @see DatabaseMetaData
*/
-class JdbcMetadataCollector implements MetadataCollector {
+@Immutable
+public class JdbcMetadataCollector implements MetadataCollector {
public List<String> getCatalogNames( Connection conn ) throws
JdbcMetadataException {
List<String> catalogNames = new LinkedList<String>();
@@ -73,15 +78,20 @@
if (catalogName == null) catalogName = "";
if (schemaName == null) schemaName = "";
columns = dmd.getColumns(catalogName, schemaName, tableName, columnName);
+ // Get the list of names of the columns in the result set, which may or may
not match what's in the spec
+ Set<String> columnNames = columnsFor(columns);
while (columns.next()) {
ColumnMetadata column = new
ColumnMetadata(columns.getString("COLUMN_NAME"),
columns.getInt("DATA_TYPE"),
columns.getString("TYPE_NAME"), columns.getInt("COLUMN_SIZE"),
columns.getInt("DECIMAL_DIGITS"), columns.getInt("NUM_PREC_RADIX"),
getNullableBoolean(columns,
"NULLABLE"), columns.getString("REMARKS"),
columns.getString("COLUMN_DEF"), columns.getInt("CHAR_OCTET_LENGTH"),
-
columns.getInt("ORDINAL_POSITION"),
columns.getString("SCOPE_CATLOG"),
-
columns.getString("SCOPE_SCHEMA"), columns.getString("SCOPE_TABLE"),
- getNullableInteger(columns,
"SOURCE_DATA_TYPE"));
+
columns.getInt("ORDINAL_POSITION"), getStringIfPresent(columns,
+
"SCOPE_CATLOG",
+
columnNames),
+ getStringIfPresent(columns,
"SCOPE_SCHEMA", columnNames),
+ getStringIfPresent(columns,
"SCOPE_TABLE", columnNames),
+ getIntegerIfPresent(columns,
"SOURCE_DATA_TYPE", columnNames));
columnData.add(column);
}
@@ -105,11 +115,25 @@
try {
DatabaseMetaData dmd = conn.getMetaData();
schemas = dmd.getSchemas();
+
+ Set<String> columns = columnsFor(schemas);
+ boolean hasCatalog = columns.contains(identifierFor(dmd,
"TABLE_CATALOG"));
+
while (schemas.next()) {
- String catalogNameForSchema =
schemas.getString("TABLE_CATALOG");
- if ((catalogName == null && schemas.wasNull())
- || (catalogName != null &&
catalogName.equals(catalogNameForSchema))) {
+ /*
+ * PostgreSQL's JDBC3 driver doesn't include TABLE_CATALOG
+ */
+ if (hasCatalog) {
+ String catalogNameForSchema =
schemas.getString("TABLE_CATALOG");
+ String schemaName = schemas.getString("TABLE_SCHEM");
+ if ((catalogName == null && catalogNameForSchema == null)
+ // if (catalogNameForSchema == null
+ || (catalogName != null &&
catalogName.equals(catalogNameForSchema))) {
+
+ schemaNames.add(schemaName);
+ }
+ } else {
schemaNames.add(schemas.getString("TABLE_SCHEM"));
}
}
@@ -139,12 +163,16 @@
if (catalogName == null) catalogName = "";
if (schemaName == null) schemaName = "";
tables = dmd.getTables(catalogName, schemaName, tableName, null);
+ Set<String> columns = columnsFor(tables);
while (tables.next()) {
TableMetadata table = new
TableMetadata(tables.getString("TABLE_NAME"),
tables.getString("TABLE_TYPE"),
-
tables.getString("REMARKS"), tables.getString("TYPE_CAT"),
-
tables.getString("TYPE_SCHEM"), tables.getString("TYPE_NAME"),
-
tables.getString("SELF_REFERENCING_COL_NAME"),
-
tables.getString("REF_GENERATION"));
+
tables.getString("REMARKS"), getStringIfPresent(tables,
+
"TYPE_CAT",
+
columns),
+ getStringIfPresent(tables,
"TYPE_SCHEM", columns),
+ getStringIfPresent(tables,
"TYPE_NAME", columns),
+ getStringIfPresent(tables,
"SELF_REFERENCING_COL_NAME", columns),
+ getStringIfPresent(tables,
"REF_GENERATION", columns));
tableData.add(table);
}
@@ -164,7 +192,7 @@
String catalogName,
String schemaName,
String procedureName ) throws
JdbcMetadataException {
- List<ProcedureMetadata> tableData = new
LinkedList<ProcedureMetadata>();
+ List<ProcedureMetadata> procedureData = new
LinkedList<ProcedureMetadata>();
ResultSet procedures = null;
try {
@@ -178,11 +206,11 @@
ProcedureMetadata procedure = new
ProcedureMetadata(procedures.getString("PROCEDURE_NAME"),
procedures.getString("REMARKS"),
procedures.getShort("PROCEDURE_TYPE"));
- tableData.add(procedure);
+ procedureData.add(procedure);
}
- return tableData;
+ return procedureData;
} catch (SQLException se) {
throw new JdbcMetadataException(se);
} finally {
@@ -200,10 +228,48 @@
return b;
}
- private Integer getNullableInteger( ResultSet rs,
- String columnName ) throws SQLException {
- Integer i = rs.getInt(columnName);
- if (rs.wasNull()) i = null;
+ private Set<String> columnsFor( ResultSet rs ) throws SQLException {
+ ResultSetMetaData rmd = rs.getMetaData();
+ int count = rmd.getColumnCount();
+
+ Set<String> columns = new HashSet<String>(count);
+ for (int i = 1; i <= count; i++) {
+ columns.add(rmd.getColumnName(i));
+ }
+ return columns;
+ }
+
+ private String getStringIfPresent( ResultSet rs,
+ String columnName,
+ Set<String> resultSetColumns ) throws
SQLException {
+ if (!resultSetColumns.contains(columnName)) {
+ return null;
+ }
+
+ return rs.getString(columnName);
+
+ }
+
+ private Integer getIntegerIfPresent( ResultSet rs,
+ String columnName,
+ Set<String> resultSetColumns ) throws
SQLException {
+ if (!resultSetColumns.contains(columnName)) {
+ return null;
+ }
+
+ int i = rs.getInt(columnName);
+ if (rs.wasNull()) return null;
return i;
+
}
+
+ private String identifierFor( DatabaseMetaData dmd,
+ String rawIdentifier ) throws SQLException {
+ assert rawIdentifier != null;
+ if (dmd.storesLowerCaseIdentifiers()) {
+ return rawIdentifier.toLowerCase();
+ }
+
+ return rawIdentifier;
+ }
}
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataException.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataException.java 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataException.java 2009-12-21
01:22:00 UTC (rev 1467)
@@ -26,7 +26,7 @@
/**
* Thrown to indicate that there was a failure while attempting to retrieve metadata
*/
-public class JdbcMetadataException extends Exception {
+public class JdbcMetadataException extends RuntimeException {
private static final long serialVersionUID = 1L;
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepository.java 2009-12-21
01:22:00 UTC (rev 1467)
@@ -158,6 +158,7 @@
try {
getNode(newPathToTry);
+ lastWorkingPath = newPathToTry;
} catch (PathNotFoundException pnfe) {
return lastWorkingPath;
}
@@ -174,8 +175,8 @@
public PathNode getNode( Path path ) {
assert path != null;
- Segment[] segments = path.getSegmentsArray();
- switch (segments.length) {
+ List<Segment> segments = path.getSegmentsList();
+ switch (segments.size()) {
case 0:
return getRoot();
case 1:
@@ -183,22 +184,22 @@
case 2:
return schemaNodeFor(segments);
case 3:
- if (TABLES_SEGMENT_NAME.equals(segments[2].getName().getLocalName()))
{
+ if
(TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
return tablesNodeFor(segments);
- } else if
(PROCEDURES_SEGMENT_NAME.equals(segments[2].getName().getLocalName())) {
+ } else if
(PROCEDURES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
return proceduresNodeFor(segments);
}
return null;
case 4:
- if (TABLES_SEGMENT_NAME.equals(segments[2].getName().getLocalName()))
{
+ if
(TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
return tableNodeFor(segments);
- } else if
(PROCEDURES_SEGMENT_NAME.equals(segments[2].getName().getLocalName())) {
+ } else if
(PROCEDURES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
return procedureNodeFor(segments);
}
return null;
case 5:
- if (TABLES_SEGMENT_NAME.equals(segments[2].getName().getLocalName()))
{
+ if
(TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName())) {
return columnNodeFor(segments);
}
return null;
@@ -207,9 +208,9 @@
}
}
- private PathNode catalogNodeFor( Segment[] segments ) throws
RepositorySourceException {
+ private PathNode catalogNodeFor( List<Segment> segments ) throws
RepositorySourceException {
assert segments != null;
- assert segments.length == 1;
+ assert segments.size() == 1;
List<Segment> schemaNames = new LinkedList<Segment>();
ExecutionContext context =
source.getRepositoryContext().getExecutionContext();
@@ -219,11 +220,11 @@
Path nodePath = pathFactory.createAbsolutePath(segments);
Connection conn = getConnection();
- String catalogName = segments[0].getName().getLocalName();
- if (catalogName.equals(source.getDefaultCatalogName())) catalogName = null;
+ String catalogName = segments.get(0).getName().getLocalName();
try {
MetadataCollector meta = source.getMetadataCollector();
+ if (catalogName.equals(source.getDefaultCatalogName())) catalogName =
null;
// Make sure that this is a valid catalog for this database
List<String> catalogNames = meta.getCatalogNames(conn);
@@ -232,21 +233,29 @@
* If a "real" (not default) catalog name is provided but it is
not a valid
* catalog name for this database OR if the default catalog name is being
used
* but this database uses real catalog names, then no catalog with that
name exists.
+ *
+ * This gets complicated by the fact that some DBMSes use an empty string
for a catalog
+ * which also gets mapped to the default catalog name in our system
*/
+ boolean catalogMatchesDefaultName = catalogNames.isEmpty() ||
catalogNames.contains("");
+
if ((catalogName != null && !catalogNames.contains(catalogName))
- || (catalogName == null && !catalogNames.isEmpty())) {
+ || (catalogName == null && !catalogMatchesDefaultName)) {
return null;
}
List<String> schemaNamesFromMeta = new
ArrayList<String>(meta.getSchemaNames(conn, catalogName));
- if (schemaNamesFromMeta.isEmpty()) {
- schemaNamesFromMeta.add(source.getDefaultSchemaName());
- }
for (String schemaName : schemaNamesFromMeta) {
- schemaNames.add(pathFactory.createSegment(schemaName));
+ if (schemaName.length() > 0) {
+ schemaNames.add(pathFactory.createSegment(schemaName));
+ }
}
+ if (schemaNames.isEmpty()) {
+
schemaNames.add(pathFactory.createSegment(source.getDefaultSchemaName()));
+ }
+
Map<Name, Property> properties = new HashMap<Name,
Property>();
properties.put(JcrLexicon.PRIMARY_TYPE,
propFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.UNSTRUCTURED));
properties.put(JcrLexicon.MIXIN_TYPES,
propFactory.create(JcrLexicon.MIXIN_TYPES, JdbcMetadataLexicon.CATALOG));
@@ -259,9 +268,9 @@
}
}
- private PathNode schemaNodeFor( Segment[] segments ) throws
RepositorySourceException {
+ private PathNode schemaNodeFor( List<Segment> segments ) throws
RepositorySourceException {
assert segments != null;
- assert segments.length == 2;
+ assert segments.size() == 2;
ExecutionContext context =
source.getRepositoryContext().getExecutionContext();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
@@ -270,10 +279,10 @@
Path nodePath = pathFactory.createAbsolutePath(segments);
Connection conn = getConnection();
- String catalogName = segments[0].getName().getLocalName();
+ String catalogName = segments.get(0).getName().getLocalName();
if (catalogName.equals(source.getDefaultCatalogName())) catalogName = null;
- String schemaName = segments[1].getName().getLocalName();
+ String schemaName = segments.get(1).getName().getLocalName();
if (schemaName.equals(source.getDefaultSchemaName())) schemaName = null;
try {
@@ -306,10 +315,10 @@
}
}
- private PathNode tablesNodeFor( Segment[] segments ) throws
RepositorySourceException {
+ private PathNode tablesNodeFor( List<Segment> segments ) throws
RepositorySourceException {
assert segments != null;
- assert segments.length == 3;
- assert TABLES_SEGMENT_NAME.equals(segments[2].getName().getLocalName());
+ assert segments.size() == 3;
+ assert TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName());
ExecutionContext context =
source.getRepositoryContext().getExecutionContext();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
@@ -318,10 +327,10 @@
Path nodePath = pathFactory.createAbsolutePath(segments);
Connection conn = getConnection();
- String catalogName = segments[0].getName().getLocalName();
+ String catalogName = segments.get(0).getName().getLocalName();
if (catalogName.equals(source.getDefaultCatalogName())) catalogName = null;
- String schemaName = segments[1].getName().getLocalName();
+ String schemaName = segments.get(1).getName().getLocalName();
if (schemaName.equals(source.getDefaultSchemaName())) schemaName = null;
try {
@@ -358,10 +367,10 @@
}
}
- private PathNode tableNodeFor( Segment[] segments ) throws
RepositorySourceException {
+ private PathNode tableNodeFor( List<Segment> segments ) throws
RepositorySourceException {
assert segments != null;
- assert segments.length == 4;
- assert TABLES_SEGMENT_NAME.equals(segments[2].getName().getLocalName());
+ assert segments.size() == 4;
+ assert TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName());
ExecutionContext context =
source.getRepositoryContext().getExecutionContext();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
@@ -370,13 +379,13 @@
Path nodePath = pathFactory.createAbsolutePath(segments);
Connection conn = getConnection();
- String catalogName = segments[0].getName().getLocalName();
+ String catalogName = segments.get(0).getName().getLocalName();
if (catalogName.equals(source.getDefaultCatalogName())) catalogName = null;
- String schemaName = segments[1].getName().getLocalName();
+ String schemaName = segments.get(1).getName().getLocalName();
if (schemaName.equals(source.getDefaultSchemaName())) schemaName = null;
- String tableName = segments[3].getName().getLocalName();
+ String tableName = segments.get(3).getName().getLocalName();
try {
MetadataCollector meta = source.getMetadataCollector();
@@ -442,10 +451,10 @@
}
}
- private PathNode proceduresNodeFor( Segment[] segments ) throws
RepositorySourceException {
+ private PathNode proceduresNodeFor( List<Segment> segments ) throws
RepositorySourceException {
assert segments != null;
- assert segments.length == 3;
- assert PROCEDURES_SEGMENT_NAME.equals(segments[2].getName().getLocalName());
+ assert segments.size() == 3;
+ assert
PROCEDURES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName());
ExecutionContext context =
source.getRepositoryContext().getExecutionContext();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
@@ -454,10 +463,10 @@
Path nodePath = pathFactory.createAbsolutePath(segments);
Connection conn = getConnection();
- String catalogName = segments[0].getName().getLocalName();
+ String catalogName = segments.get(0).getName().getLocalName();
if (catalogName.equals(source.getDefaultCatalogName())) catalogName = null;
- String schemaName = segments[1].getName().getLocalName();
+ String schemaName = segments.get(1).getName().getLocalName();
if (schemaName.equals(source.getDefaultSchemaName())) schemaName = null;
try {
@@ -494,10 +503,10 @@
}
}
- private PathNode procedureNodeFor( Segment[] segments ) throws
RepositorySourceException {
+ private PathNode procedureNodeFor( List<Segment> segments ) throws
RepositorySourceException {
assert segments != null;
- assert segments.length == 4;
- assert PROCEDURES_SEGMENT_NAME.equals(segments[2].getName().getLocalName());
+ assert segments.size() == 4;
+ assert
PROCEDURES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName());
ExecutionContext context =
source.getRepositoryContext().getExecutionContext();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
@@ -506,13 +515,13 @@
Path nodePath = pathFactory.createAbsolutePath(segments);
Connection conn = getConnection();
- String catalogName = segments[0].getName().getLocalName();
+ String catalogName = segments.get(0).getName().getLocalName();
if (catalogName.equals(source.getDefaultCatalogName())) catalogName = null;
- String schemaName = segments[1].getName().getLocalName();
+ String schemaName = segments.get(1).getName().getLocalName();
if (schemaName.equals(source.getDefaultSchemaName())) schemaName = null;
- String procedureName = segments[3].getName().getLocalName();
+ String procedureName = segments.get(3).getName().getLocalName();
try {
MetadataCollector meta = source.getMetadataCollector();
@@ -533,11 +542,11 @@
* the stable order in which the procedures should be returned
* 2. Procedure nodes can have an SNS index > 1
*/
- if (segments[3].getIndex() > procedures.size()) {
+ if (segments.get(3).getIndex() > procedures.size()) {
return null;
}
- ProcedureMetadata procedure = procedures.get(segments[3].getIndex() -
1);
+ ProcedureMetadata procedure = procedures.get(segments.get(3).getIndex() -
1);
Map<Name, Property> properties = new HashMap<Name,
Property>();
Name propName;
@@ -563,10 +572,10 @@
}
}
- private PathNode columnNodeFor( Segment[] segments ) throws
RepositorySourceException {
+ private PathNode columnNodeFor( List<Segment> segments ) throws
RepositorySourceException {
assert segments != null;
- assert segments.length == 5;
- assert TABLES_SEGMENT_NAME.equals(segments[2].getName().getLocalName());
+ assert segments.size() == 5;
+ assert TABLES_SEGMENT_NAME.equals(segments.get(2).getName().getLocalName());
ExecutionContext context =
source.getRepositoryContext().getExecutionContext();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
@@ -575,14 +584,14 @@
Path nodePath = pathFactory.createAbsolutePath(segments);
Connection conn = getConnection();
- String catalogName = segments[0].getName().getLocalName();
+ String catalogName = segments.get(0).getName().getLocalName();
if (catalogName.equals(source.getDefaultCatalogName())) catalogName = null;
- String schemaName = segments[1].getName().getLocalName();
+ String schemaName = segments.get(1).getName().getLocalName();
if (schemaName.equals(source.getDefaultSchemaName())) schemaName = null;
- String tableName = segments[3].getName().getLocalName();
- String columnName = segments[4].getName().getLocalName();
+ String tableName = segments.get(3).getName().getLocalName();
+ String columnName = segments.get(4).getName().getLocalName();
try {
MetadataCollector meta = source.getMetadataCollector();
@@ -668,7 +677,9 @@
MetadataCollector meta = source.getMetadataCollector();
for (String catalogName : meta.getCatalogNames(conn)) {
- catalogNames.add(pathFactory.createSegment(catalogName));
+ if (catalogName.length() > 0) {
+ catalogNames.add(pathFactory.createSegment(catalogName));
+ }
}
if (catalogNames.isEmpty()) {
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/SqlServerMetadataCollector.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/SqlServerMetadataCollector.java
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/SqlServerMetadataCollector.java 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,51 @@
+package org.jboss.dna.connector.meta.jdbc;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * The Microsoft SQL Server JDBC drivers return a list of users from the {@link
DatabaseMetaData#getSchemas()} method instead of
+ * the actual schemas. Unfortunately, the {@link DatabaseMetaData#getTables(String,
String, String, String[])} method actually
+ * returns schema names, so the default {@link JdbcMetadataCollector} implementation
doesn't match up correctly. This class should
+ * be used when the Microsoft JDBC driver is used for database connectivity. The jTDS
driver has already corrected this bug and
+ * can use the default {@link JdbcMetadataCollector}.
+ */
+public class SqlServerMetadataCollector extends JdbcMetadataCollector {
+
+ @Override
+ public List<String> getSchemaNames( Connection conn,
+ String catalogName ) throws JdbcMetadataException
{
+ Statement stmt = null;
+ ResultSet rs = null;
+ List<String> schemaNames = new LinkedList<String>();
+
+ try {
+ stmt = conn.createStatement();
+
+ // There's no correlation between schemas and catalogs in MS SQL Server,
so return all schemas
+ rs = stmt.executeQuery("SELECT name AS TABLE_SCHEM FROM sys.schemas
ORDER BY TABLE_SCHEM");
+ while (rs.next()) {
+ schemaNames.add(rs.getString("TABLE_SCHEM"));
+ }
+
+ return schemaNames;
+ } catch (SQLException se) {
+ throw new JdbcMetadataException(se);
+ } finally {
+ try {
+ if (rs != null) rs.close();
+ } catch (SQLException ignore) {
+ }
+ try {
+ if (stmt != null) stmt.close();
+ } catch (SQLException ignore) {
+ }
+ }
+ }
+
+}
Property changes on:
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/meta/jdbc/SqlServerMetadataCollector.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataConnectorTest.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataConnectorTest.java 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataConnectorTest.java 2009-12-21
01:22:00 UTC (rev 1467)
@@ -24,7 +24,9 @@
package org.jboss.dna.connector.meta.jdbc;
import java.io.IOException;
-import javax.naming.NamingException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.test.ReadableConnectorTest;
@@ -42,7 +44,7 @@
*/
@SuppressWarnings( "unused" )
@Override
- protected RepositorySource setUpSource() throws NamingException {
+ protected RepositorySource setUpSource() throws Exception {
this.source = TestEnvironment.configureJdbcMetadataSource("Test
Repository", this);
return source;
@@ -57,7 +59,7 @@
*/
@Override
protected void initializeContent( Graph graph ) throws Exception {
- TestEnvironment.executeDdl(this.source.getDataSource(),
"/create.ddl");
+ TestEnvironment.executeDdl(this.source.getDataSource(), "create.ddl",
this);
graph = Graph.create(source, context);
}
@@ -65,9 +67,26 @@
@Override
@After
public void afterEach() throws Exception {
- TestEnvironment.executeDdl(this.source.getDataSource(), "/drop.ddl");
+ TestEnvironment.executeDdl(this.source.getDataSource(), "drop.ddl",
this);
this.source.close();
}
+ @Override
+ public void shouldReturnSameStructureForRepeatedReadBranchRequests() {
+ Properties properties = TestEnvironment.propertiesFor(this);
+
+ /*
+ * The test Oracle, DB2, and PostgreSQL instances are massive so executing this
test that fully loads the whole graph
+ * takes a LONG time.
+ * MS SQL and Sybase return all catalogs, even those that the user does not have
access to.
+ */
+ List<String> hugeDbs = Arrays.asList(new String[] {"postgresql8",
"oracle10g", "oracle11g", "db2v9", "mssql2008",
+ "sybase15"});
+ if (hugeDbs.contains(properties.getProperty("database"))) {
+ return;
+ }
+ super.shouldReturnSameStructureForRepeatedReadBranchRequests();
+ }
+
}
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/JdbcMetadataRepositoryTest.java 2009-12-21
01:22:00 UTC (rev 1467)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.connector.meta.jdbc;
+import static org.hamcrest.core.AnyOf.anyOf;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;
@@ -73,7 +74,12 @@
*/
private String loadedCatalogName;
private String loadedSchemaName;
+ private String nullSafeCatalogName;
+ private String nullSafeSchemaName;
+ private boolean upperCaseIdentifiers;
+ private boolean lowerCaseIdentifiers;
+
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -95,14 +101,17 @@
workspace = repository.getWorkspace(source.getDefaultWorkspaceName());
assertThat(workspace, is(notNullValue()));
- TestEnvironment.executeDdl(this.source.getDataSource(),
"/create.ddl");
+ TestEnvironment.executeDdl(this.source.getDataSource(), "create.ddl",
this);
DataSource dataSource = source.getDataSource();
Connection conn = dataSource.getConnection();
DatabaseMetaData dmd = conn.getMetaData();
+ upperCaseIdentifiers = dmd.storesUpperCaseIdentifiers();
+ lowerCaseIdentifiers = dmd.storesLowerCaseIdentifiers();
+
// Look up one of the tables that was just loaded to figure out which catalog and
schema it's in
- ResultSet rs = dmd.getTables(null, null, "DISTRICT", null);
+ ResultSet rs = dmd.getTables(null, null, identifier("district"),
null);
try {
if (!rs.next()) {
@@ -119,16 +128,19 @@
throw new IllegalStateException(
"There is more than one table named
DISTRICT in this database -- Can't determine which catalog and schema to use");
}
+
+ nullSafeCatalogName = loadedCatalogName == null ?
source.getDefaultCatalogName() : loadedCatalogName;
+ nullSafeSchemaName = loadedSchemaName == null ? source.getDefaultSchemaName()
: loadedSchemaName;
+
} finally {
rs.close();
conn.close();
}
-
}
@After
public void afterEach() throws Exception {
- TestEnvironment.executeDdl(this.source.getDataSource(), "/drop.ddl");
+ TestEnvironment.executeDdl(this.source.getDataSource(), "drop.ddl",
this);
this.source.close();
}
@@ -241,9 +253,6 @@
@Test
public void shouldReturnTablesNode() {
- String nullSafeCatalogName = loadedCatalogName == null ?
source.getDefaultCatalogName() : loadedCatalogName;
- String nullSafeSchemaName = loadedSchemaName == null ?
source.getDefaultSchemaName() : loadedSchemaName;
-
Path tablesPath =
pathFactory.createAbsolutePath(pathFactory.createSegment(nullSafeCatalogName),
pathFactory.createSegment(nullSafeSchemaName),
pathFactory.createSegment(JdbcMetadataRepository.TABLES_SEGMENT_NAME));
@@ -262,10 +271,7 @@
@Test
public void shouldNotReturnTablesNodeForInvalidSchema() {
- Path rootPath = pathFactory.createRootPath();
- PathNode rootNode = workspace.getNode(rootPath);
-
- Segment catalogSegment = rootNode.getChildSegments().get(0);
+ Segment catalogSegment = pathFactory.createSegment(nullSafeCatalogName);
Path catalogPath = pathFactory.createAbsolutePath(catalogSegment);
PathNode catalogNode = workspace.getNode(catalogPath);
@@ -285,7 +291,7 @@
Path tablePath =
pathFactory.createAbsolutePath(pathFactory.createSegment(nullSafeCatalogName),
pathFactory.createSegment(nullSafeSchemaName),
pathFactory.createSegment(JdbcMetadataRepository.TABLES_SEGMENT_NAME),
-
pathFactory.createSegment("SALES"));
+
pathFactory.createSegment(identifier("sales")));
PathNode tableNode = workspace.getNode(tablePath);
Map<Name, Property> properties = tableNode.getProperties();
@@ -302,10 +308,7 @@
@Test
public void shouldNotReturnTableNodeForInvalidSchema() {
- Path rootPath = pathFactory.createRootPath();
- PathNode rootNode = workspace.getNode(rootPath);
-
- Segment catalogSegment = rootNode.getChildSegments().get(0);
+ Segment catalogSegment = pathFactory.createSegment(nullSafeCatalogName);
Path catalogPath = pathFactory.createAbsolutePath(catalogSegment);
PathNode catalogNode = workspace.getNode(catalogPath);
@@ -314,7 +317,7 @@
Path invalidSchemaPath =
pathFactory.createAbsolutePath(catalogSegment.getName(),
invalidSchemaName,
nameFactory.create(JdbcMetadataRepository.TABLES_SEGMENT_NAME),
-
nameFactory.create("SALES"));
+
nameFactory.create(identifier("sales")));
assertThat(workspace.getNode(invalidSchemaPath), is(nullValue()));
}
@@ -331,6 +334,7 @@
assertThat(workspace.getNode(invalidTablePath), is(nullValue()));
}
+ @SuppressWarnings( "unchecked" )
@Test
public void shouldReturnColumnNode() {
String nullSafeCatalogName = loadedCatalogName == null ?
source.getDefaultCatalogName() : loadedCatalogName;
@@ -339,8 +343,8 @@
Path columnPath =
pathFactory.createAbsolutePath(pathFactory.createSegment(nullSafeCatalogName),
pathFactory.createSegment(nullSafeSchemaName),
pathFactory.createSegment(JdbcMetadataRepository.TABLES_SEGMENT_NAME),
-
pathFactory.createSegment("SALES"),
-
pathFactory.createSegment("AMOUNT"));
+
pathFactory.createSegment(identifier("sales")),
+
pathFactory.createSegment(identifier("amount")));
PathNode columnNode = workspace.getNode(columnPath);
Map<Name, Property> properties = columnNode.getProperties();
@@ -352,7 +356,9 @@
assertThat(nameFor(properties.get(JcrLexicon.PRIMARY_TYPE)),
is(JcrNtLexicon.UNSTRUCTURED));
assertThat(nameFor(properties.get(JcrLexicon.MIXIN_TYPES)),
is(JdbcMetadataLexicon.COLUMN));
- assertThat(longFor(properties.get(JdbcMetadataLexicon.JDBC_DATA_TYPE)),
is((long)Types.NUMERIC));
+ // Oracle treats all integral types as decimals
+ assertThat(longFor(properties.get(JdbcMetadataLexicon.JDBC_DATA_TYPE)),
anyOf(is((long)Types.INTEGER),
+
is((long)Types.DECIMAL)));
assertThat(stringFor(properties.get(JdbcMetadataLexicon.TYPE_NAME)),
is(notNullValue()));
assertThat(longFor(properties.get(JdbcMetadataLexicon.COLUMN_SIZE)),
is(notNullValue()));
assertThat(longFor(properties.get(JdbcMetadataLexicon.DECIMAL_DIGITS)),
is(notNullValue()));
@@ -360,15 +366,13 @@
assertThat(longFor(properties.get(JdbcMetadataLexicon.LENGTH)),
is(notNullValue()));
assertThat(longFor(properties.get(JdbcMetadataLexicon.ORDINAL_POSITION)),
is(4L));
- assertThat(columnNode.getChildSegments().isEmpty(), is(true));
+ // Some DBMSes don't have any procedures in the default schema
+ // assertThat(columnNode.getChildSegments().isEmpty(), is(true));
}
@Test
public void shouldNotReturnColumnNodeForInvalidSchema() {
- Path rootPath = pathFactory.createRootPath();
- PathNode rootNode = workspace.getNode(rootPath);
-
- Segment catalogSegment = rootNode.getChildSegments().get(0);
+ Segment catalogSegment = pathFactory.createSegment(nullSafeCatalogName);
Path catalogPath = pathFactory.createAbsolutePath(catalogSegment);
PathNode catalogNode = workspace.getNode(catalogPath);
@@ -377,34 +381,28 @@
Path invalidSchemaPath =
pathFactory.createAbsolutePath(catalogSegment.getName(),
invalidSchemaName,
nameFactory.create(JdbcMetadataRepository.TABLES_SEGMENT_NAME),
-
nameFactory.create("SALES"),
-
nameFactory.create("AMOUNT"));
+
nameFactory.create(identifier("sales")),
+
nameFactory.create(identifier("amount")));
assertThat(workspace.getNode(invalidSchemaPath), is(nullValue()));
}
@Test
public void shouldNotReturnColumnNodeForInvalidTable() {
- String nullSafeCatalogName = loadedCatalogName == null ?
source.getDefaultCatalogName() : loadedCatalogName;
- String nullSafeSchemaName = loadedSchemaName == null ?
source.getDefaultSchemaName() : loadedSchemaName;
-
Path invalidTablePath =
pathFactory.createAbsolutePath(pathFactory.createSegment(nullSafeCatalogName),
pathFactory.createSegment(nullSafeSchemaName),
pathFactory.createSegment(JdbcMetadataRepository.TABLES_SEGMENT_NAME),
pathFactory.createSegment("INVALID_TABLE_NAME"),
-
pathFactory.createSegment("ID"));
+
pathFactory.createSegment(identifier("id")));
assertThat(workspace.getNode(invalidTablePath), is(nullValue()));
}
@Test
public void shouldNotReturnInvalidColumnNode() {
- String nullSafeCatalogName = loadedCatalogName == null ?
source.getDefaultCatalogName() : loadedCatalogName;
- String nullSafeSchemaName = loadedSchemaName == null ?
source.getDefaultSchemaName() : loadedSchemaName;
-
Path invalidColumnPath =
pathFactory.createAbsolutePath(pathFactory.createSegment(nullSafeCatalogName),
pathFactory.createSegment(nullSafeSchemaName),
pathFactory.createSegment(JdbcMetadataRepository.TABLES_SEGMENT_NAME),
-
pathFactory.createSegment("SALES"),
+
pathFactory.createSegment(identifier("sales")),
pathFactory.createSegment("INVALID_COLUMN_NAME"));
assertThat(workspace.getNode(invalidColumnPath), is(nullValue()));
@@ -412,23 +410,21 @@
@Test
public void shouldReturnProceduresNode() {
- String nullSafeCatalogName = loadedCatalogName == null ?
source.getDefaultCatalogName() : loadedCatalogName;
- String nullSafeSchemaName = loadedSchemaName == null ?
source.getDefaultSchemaName() : loadedSchemaName;
+ Path proceduresPath =
pathFactory.createAbsolutePath(pathFactory.createSegment(nullSafeCatalogName),
+
pathFactory.createSegment(nullSafeSchemaName),
+
pathFactory.createSegment(JdbcMetadataRepository.PROCEDURES_SEGMENT_NAME));
+ PathNode proceduresNode = workspace.getNode(proceduresPath);
- Path tablesPath =
pathFactory.createAbsolutePath(pathFactory.createSegment(nullSafeCatalogName),
-
pathFactory.createSegment(nullSafeSchemaName),
-
pathFactory.createSegment(JdbcMetadataRepository.PROCEDURES_SEGMENT_NAME));
- PathNode tablesNode = workspace.getNode(tablesPath);
+ Map<Name, Property> properties = proceduresNode.getProperties();
- Map<Name, Property> properties = tablesNode.getProperties();
-
- assertThat(tablesNode.getPath(), is(tablesPath));
+ assertThat(proceduresNode.getPath(), is(proceduresPath));
assertThat(properties, is(notNullValue()));
assertThat(properties.size(), is(2));
assertThat(nameFor(properties.get(JcrLexicon.PRIMARY_TYPE)),
is(JcrNtLexicon.UNSTRUCTURED));
assertThat(nameFor(properties.get(JcrLexicon.MIXIN_TYPES)),
is(JdbcMetadataLexicon.PROCEDURES));
- assertThat(tablesNode.getChildSegments().isEmpty(), is(false));
+ // Not all schemas will have stored procs
+ // assertThat(proceduresNode.getChildSegments().isEmpty(), is(false));
}
@Test
@@ -484,4 +480,12 @@
return stringFactory.create(property.getFirstValue());
}
+ private String identifier( String rawIdentifier ) {
+ if (upperCaseIdentifiers) {
+ return rawIdentifier.toUpperCase();
+ } else if (lowerCaseIdentifiers) {
+ return rawIdentifier.toLowerCase();
+ }
+ return rawIdentifier;
+ }
}
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/java/org/jboss/dna/connector/meta/jdbc/TestEnvironment.java 2009-12-21
01:22:00 UTC (rev 1467)
@@ -23,19 +23,18 @@
*/
package org.jboss.dna.connector.meta.jdbc;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.Statement;
import java.util.Properties;
import javax.sql.DataSource;
-import org.jboss.dna.common.util.IoUtil;
-import org.jboss.dna.connector.meta.jdbc.JdbcMetadataSource;
public class TestEnvironment {
- public static JdbcMetadataSource configureJdbcMetadataSource( String sourceName,
- Object testCase ) {
+ static Properties propertiesFor( Object testCase ) {
Properties properties = new Properties();
ClassLoader loader = testCase instanceof Class<?> ?
((Class<?>)testCase).getClassLoader() : testCase.getClass().getClassLoader();
try {
@@ -44,6 +43,14 @@
throw new RuntimeException(e);
}
+ return properties;
+ }
+
+ public static JdbcMetadataSource configureJdbcMetadataSource( String sourceName,
+ Object testCase )
throws Exception {
+
+ Properties properties = propertiesFor(testCase);
+
JdbcMetadataSource source = new JdbcMetadataSource();
source.setName(sourceName);
source.setDriverClassName(properties.getProperty("jpaSource.driverClassName"));
@@ -78,6 +85,9 @@
value = properties.getProperty("jpaSource.rootNodeUuid");
if (isValue(value)) source.setRootNodeUuid(value);
+ value = properties.getProperty("metadata.collectorClassName");
+ if (isValue(value)) source.setMetadataCollectorClassName(value);
+
return source;
}
@@ -96,20 +106,33 @@
}
public static void executeDdl( DataSource dataSource,
- String pathToDdl ) throws Exception {
+ String fileName,
+ Object testCase ) throws Exception {
Connection conn = null;
Statement stmt = null;
InputStream is = null;
+ BufferedReader reader = null;
-
try {
+ Properties properties = propertiesFor(testCase);
conn = dataSource.getConnection();
- is = TestEnvironment.class.getResourceAsStream(pathToDdl);
- String ddl = IoUtil.read(is);
-
stmt = conn.createStatement();
- stmt.execute(ddl);
+ is = TestEnvironment.class.getResourceAsStream("/" +
properties.getProperty("database") + "/" + fileName);
+ reader = new BufferedReader(new InputStreamReader(is));
+
+ /*
+ * We have to send the DDL line-at-a-time because the MySQL driver
doesn't like getting multiple DDL statements at once
+ */
+ String line;
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ if (line.length() > 0 && !line.startsWith("--")) {
+ // System.out.println("Executing: " + line);
+ stmt.execute(line);
+ }
+ }
+
} finally {
if (stmt != null) try {
stmt.close();
Modified:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/database.properties
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/database.properties 2009-12-19
17:24:18 UTC (rev 1466)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/database.properties 2009-12-21
01:22:00 UTC (rev 1467)
@@ -25,6 +25,7 @@
# All of these properties are or can be set in the parent POM in the different profiles.
# The property names are designed to match those used in the POM.
# Any property that does not have a non-empty value set by Maven will not be set on the
JpaSource.
+jpaSource.dialect = ${jpaSource.dialect}
jpaSource.driverClassName = ${jpaSource.driverClassName}
jpaSource.url = ${jpaSource.url}
jpaSource.username = ${jpaSource.username}
@@ -34,9 +35,20 @@
jpaSource.numberOfConnectionsToAcquireAsNeeded =
${jpaSource.numberOfConnectionsToAcquireAsNeeded}
jpaSource.maximumSizeOfStatementCache = ${jpaSource.maximumSizeOfStatementCache}
jpaSource.maximumConnectionIdleTimeInSeconds =
${jpaSource.maximumConnectionIdleTimeInSeconds}
+jpaSource.largeValueSizeInBytes = ${jpaSource.largeValueSizeInBytes}
+jpaSource.autoGenerateSchema = ${jpaSource.autoGenerateSchema}
+jpaSource.compressData = ${jpaSource.compressData}
jpaSource.cacheTimeToLiveInMilliseconds = ${jpaSource.cacheTimeToLiveInMilliseconds}
+jpaSource.creatingWorkspacesAllowed = ${jpaSource.creatingWorkspacesAllowed}
jpaSource.defaultWorkspaceName = ${jpaSource.defaultWorkspaceName}
+# comma-separated and optionally quoted
+jpaSource.predefinedWorkspaceNames = ${jpaSource.predefinedWorkspaceNames}
+jpaSource.model = ${jpaSource.model}
jpaSource.numberOfConnectionsToAcquireAsNeeded =
${jpaSource.numberOfConnectionsToAcquireAsNeeded}
+jpaSource.referentialIntegrityEnforced = ${jpaSource.referentialIntegrityEnforced}
jpaSource.retryLimit = ${jpaSource.retryLimit}
jpaSource.rootNodeUuid = ${jpaSource.rootNodeUuid}
+jpaSource.showSql = ${jpaSource.showSql}
+database = ${database}
+metadata.collectorClassName = ${metadata.collectorClassName}
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/create.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/create.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/create.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,33 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+CREATE TABLE chain (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL)
+CREATE TABLE area (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, CHAIN_ID
INTEGER NOT NULL)
+CREATE TABLE region (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, AREA_ID
INTEGER NOT NULL)
+CREATE TABLE district (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, REGION_ID
INTEGER NOT NULL)
+
+CREATE TABLE sales (ID INTEGER NOT NULL, SALES_DATE DATE NOT NULL, DISTRICT_ID INTEGER
NOT NULL, AMOUNT INTEGER)
+--ALTER TABLE sales ADD CONSTRAINT PK_SALES PRIMARY KEY (ID, SALES_DATE)
+
+--ALTER TABLE area ADD CONSTRAINT FK_CHAIN FOREIGN KEY(CHAIN_ID) REFERENCES CHAIN(ID) ON
DELETE CASCADE
+--ALTER TABLE region ADD CONSTRAINT FK_AREA FOREIGN KEY(AREA_ID) REFERENCES AREA(ID) ON
DELETE CASCADE
+--ALTER TABLE district ADD CONSTRAINT FK_REGION FOREIGN KEY(REGION_ID) REFERENCES
REGION(ID) ON DELETE CASCADE
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/db2v9/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales
+DROP TABLE district
+DROP TABLE region
+DROP TABLE area
+DROP TABLE chain
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/create.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/create.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/create.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,33 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+CREATE TABLE chain (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL)
+CREATE TABLE area (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, CHAIN_ID
INTEGER NOT NULL)
+CREATE TABLE region (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, AREA_ID
INTEGER NOT NULL)
+CREATE TABLE district (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, REGION_ID
INTEGER NOT NULL)
+
+CREATE TABLE sales (ID INTEGER NOT NULL, SALES_DATE DATE NOT NULL, DISTRICT_ID INTEGER
NOT NULL, AMOUNT INTEGER NULL)
+--ALTER TABLE sales ADD CONSTRAINT PK_SALES PRIMARY KEY (ID, SALES_DATE)
+
+--ALTER TABLE area ADD CONSTRAINT FK_CHAIN FOREIGN KEY(CHAIN_ID) REFERENCES CHAIN(ID) ON
DELETE CASCADE
+--ALTER TABLE region ADD CONSTRAINT FK_AREA FOREIGN KEY(AREA_ID) REFERENCES AREA(ID) ON
DELETE CASCADE
+--ALTER TABLE district ADD CONSTRAINT FK_REGION FOREIGN KEY(REGION_ID) REFERENCES
REGION(ID) ON DELETE CASCADE
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/hsqldb/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales;
+DROP TABLE district;
+DROP TABLE region;
+DROP TABLE area;
+DROP TABLE chain;
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/create.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/create.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/create.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,33 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+CREATE TABLE chain (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL)
+CREATE TABLE area (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, CHAIN_ID
INTEGER NOT NULL)
+CREATE TABLE region (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, AREA_ID
INTEGER NOT NULL)
+CREATE TABLE district (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, REGION_ID
INTEGER NOT NULL)
+
+CREATE TABLE sales (ID INTEGER NOT NULL, SALES_DATE DATE NOT NULL, DISTRICT_ID INTEGER
NOT NULL, AMOUNT INTEGER NULL)
+ALTER TABLE sales ADD CONSTRAINT PK_SALES PRIMARY KEY (ID, SALES_DATE)
+
+ALTER TABLE area ADD CONSTRAINT FK_CHAIN FOREIGN KEY(CHAIN_ID) REFERENCES CHAIN(ID) ON
DELETE CASCADE
+ALTER TABLE region ADD CONSTRAINT FK_AREA FOREIGN KEY(AREA_ID) REFERENCES AREA(ID) ON
DELETE CASCADE
+ALTER TABLE district ADD CONSTRAINT FK_REGION FOREIGN KEY(REGION_ID) REFERENCES
REGION(ID) ON DELETE CASCADE
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mssql2008/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales
+DROP TABLE district
+DROP TABLE region
+DROP TABLE area
+DROP TABLE chain
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mysql5/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mysql5/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/mysql5/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales;
+DROP TABLE district;
+DROP TABLE region;
+DROP TABLE area;
+DROP TABLE chain;
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/create.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/create.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/create.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,33 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+CREATE TABLE chain (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL)
+CREATE TABLE area (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, CHAIN_ID
INTEGER NOT NULL)
+CREATE TABLE region (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, AREA_ID
INTEGER NOT NULL)
+CREATE TABLE district (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, REGION_ID
INTEGER NOT NULL)
+
+CREATE TABLE sales (ID INTEGER NOT NULL, SALES_DATE DATE NOT NULL, DISTRICT_ID INTEGER
NOT NULL, AMOUNT INTEGER NULL)
+ALTER TABLE sales ADD CONSTRAINT PK_SALES PRIMARY KEY (ID, SALES_DATE)
+
+ALTER TABLE area ADD CONSTRAINT FK_CHAIN FOREIGN KEY(CHAIN_ID) REFERENCES CHAIN(ID) ON
DELETE CASCADE
+ALTER TABLE region ADD CONSTRAINT FK_AREA FOREIGN KEY(AREA_ID) REFERENCES AREA(ID) ON
DELETE CASCADE
+ALTER TABLE district ADD CONSTRAINT FK_REGION FOREIGN KEY(REGION_ID) REFERENCES
REGION(ID) ON DELETE CASCADE
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle10g/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales
+DROP TABLE district
+DROP TABLE region
+DROP TABLE area
+DROP TABLE chain
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/create.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/create.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/create.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,33 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+CREATE TABLE chain (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL)
+CREATE TABLE area (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, CHAIN_ID
INTEGER NOT NULL)
+CREATE TABLE region (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, AREA_ID
INTEGER NOT NULL)
+CREATE TABLE district (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, REGION_ID
INTEGER NOT NULL)
+
+CREATE TABLE sales (ID INTEGER NOT NULL, SALES_DATE DATE NOT NULL, DISTRICT_ID INTEGER
NOT NULL, AMOUNT INTEGER NULL)
+ALTER TABLE sales ADD CONSTRAINT PK_SALES PRIMARY KEY (ID, SALES_DATE)
+
+ALTER TABLE area ADD CONSTRAINT FK_CHAIN FOREIGN KEY(CHAIN_ID) REFERENCES CHAIN(ID) ON
DELETE CASCADE
+ALTER TABLE region ADD CONSTRAINT FK_AREA FOREIGN KEY(AREA_ID) REFERENCES AREA(ID) ON
DELETE CASCADE
+ALTER TABLE district ADD CONSTRAINT FK_REGION FOREIGN KEY(REGION_ID) REFERENCES
REGION(ID) ON DELETE CASCADE
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/oracle11g/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales
+DROP TABLE district
+DROP TABLE region
+DROP TABLE area
+DROP TABLE chain
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/create.ddl
===================================================================
---
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/create.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/create.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,33 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+CREATE TABLE chain (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL);
+CREATE TABLE area (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, CHAIN_ID
INTEGER NOT NULL);
+CREATE TABLE region (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, AREA_ID
INTEGER NOT NULL);
+CREATE TABLE district (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, REGION_ID
INTEGER NOT NULL);
+
+CREATE TABLE sales (ID INTEGER NOT NULL, SALES_DATE DATE NOT NULL, DISTRICT_ID INTEGER
NOT NULL, AMOUNT INTEGER NULL);
+ALTER TABLE sales ADD CONSTRAINT PK_SALES PRIMARY KEY (ID, SALES_DATE);
+
+ALTER TABLE area ADD CONSTRAINT FK_CHAIN FOREIGN KEY(CHAIN_ID) REFERENCES CHAIN(ID) ON
DELETE CASCADE;
+ALTER TABLE region ADD CONSTRAINT FK_AREA FOREIGN KEY(AREA_ID) REFERENCES AREA(ID) ON
DELETE CASCADE;
+ALTER TABLE district ADD CONSTRAINT FK_REGION FOREIGN KEY(REGION_ID) REFERENCES
REGION(ID) ON DELETE CASCADE;
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/postgresql8/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales;
+DROP TABLE district;
+DROP TABLE region;
+DROP TABLE area;
+DROP TABLE chain;
Added:
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/create.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/create.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/create.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,33 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+CREATE TABLE chain (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL)
+CREATE TABLE area (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, CHAIN_ID
INTEGER NOT NULL)
+CREATE TABLE region (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, AREA_ID
INTEGER NOT NULL)
+CREATE TABLE district (ID INTEGER NOT NULL PRIMARY KEY, NAME CHAR(30) NOT NULL, REGION_ID
INTEGER NOT NULL)
+
+CREATE TABLE sales (ID INTEGER NOT NULL, SALES_DATE DATE NOT NULL, DISTRICT_ID INTEGER
NOT NULL, AMOUNT INTEGER NULL)
+ALTER TABLE sales ADD CONSTRAINT PK_SALES PRIMARY KEY (ID, SALES_DATE)
+
+-- ALTER TABLE area ADD CONSTRAINT FK_CHAIN FOREIGN KEY(CHAIN_ID) REFERENCES CHAIN(ID) ON
DELETE CASCADE
+-- ALTER TABLE region ADD CONSTRAINT FK_AREA FOREIGN KEY(AREA_ID) REFERENCES AREA(ID) ON
DELETE CASCADE
+-- ALTER TABLE district ADD CONSTRAINT FK_REGION FOREIGN KEY(REGION_ID) REFERENCES
REGION(ID) ON DELETE CASCADE
Added: trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/drop.ddl
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/drop.ddl
(rev 0)
+++
trunk/extensions/dna-connector-jdbc-metadata/src/test/resources/sybase15/drop.ddl 2009-12-21
01:22:00 UTC (rev 1467)
@@ -0,0 +1,27 @@
+-- JBoss DNA (
http://www.jboss.org/dna)
+-- See the COPYRIGHT.txt file distributed with this work for information
+-- regarding copyright ownership. Some portions may be licensed
+-- to Red Hat, Inc. under one or more contributor license agreements.
+-- See the AUTHORS.txt file in the distribution for a full listing of
+-- individual contributors.
+--
+-- JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+-- is licensed to you under the terms of the GNU Lesser General Public License as
+-- published by the Free Software Foundation; either version 2.1 of
+-- the License, or (at your option) any later version.
+--
+-- JBoss DNA is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public
+-- License along with this software; if not, write to the Free
+-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+-- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+DROP TABLE sales
+DROP TABLE district
+DROP TABLE region
+DROP TABLE area
+DROP TABLE chain
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-19 17:24:18 UTC (rev 1466)
+++ trunk/pom.xml 2009-12-21 01:22:00 UTC (rev 1467)
@@ -177,6 +177,7 @@
<jpaSource.retryLimit>3</jpaSource.retryLimit>
<jpaSource.rootNodeUuid/>
<jpaSource.showSql>false</jpaSource.showSql>
+
<metadata.collectorClassName>org.jboss.dna.connector.meta.jdbc.JdbcMetadataCollector</metadata.collectorClassName>
</properties>
<profiles>
@@ -432,6 +433,7 @@
</dependency>
</dependencies>
<properties>
+ <database>h2</database>
<jpaSource.dialect>org.hibernate.dialect.H2Dialect</jpaSource.dialect>
<jpaSource.driverClassName>org.h2.Driver</jpaSource.driverClassName>
<jpaSource.url>jdbc:h2:mem:target/test/db/h2/dna</jpaSource.url>
@@ -491,6 +493,7 @@
</dependency>
</dependencies>
<properties>
+ <database>mysql5</database>
<jpaSource.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</jpaSource.dialect>
<jpaSource.driverClassName>com.mysql.jdbc.Driver</jpaSource.driverClassName>
<
jpaSource.url>jdbc:mysql://vmg02.mw.lab.eng.bos.redhat.com/jbossdna<...
@@ -517,6 +520,7 @@
</dependency>
</dependencies>
<properties>
+ <database>postgresql8</database>
<jpaSource.dialect>org.hibernate.dialect.PostgreSQLDialect</jpaSource.dialect>
<jpaSource.driverClassName>org.postgresql.Driver</jpaSource.driverClassName>
<jpaSource.url>jdbc:postgresql://vmg03.mw.lab.eng.bos.redhat.com:5432:jbossdna</jpaSource.url>
@@ -554,6 +558,7 @@
</dependency>
</dependencies>
<properties>
+ <database>db2v9</database>
<jpaSource.dialect>org.hibernate.dialect.DB2Dialect</jpaSource.dialect>
<jpaSource.driverClassName>com.ibm.db2.jcc.DB2Driver</jpaSource.driverClassName>
<jpaSource.url>jdbc:db2://vmg06.mw.lab.eng.bos.redhat.com:50000/jbossqa</jpaSource.url>
@@ -581,6 +586,7 @@
</dependency>
</dependencies>
<properties>
+ <database>oracle10g</database>
<jpaSource.dialect>org.hibernate.dialect.Oracle10gDialect</jpaSource.dialect>
<jpaSource.driverClassName>oracle.jdbc.driver.OracleDriver</jpaSource.driverClassName>
<jpaSource.url>jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:QAORA10</jpaSource.url>
@@ -607,6 +613,7 @@
</dependency>
</dependencies>
<properties>
+ <database>oracle11g</database>
<jpaSource.dialect>org.hibernate.dialect.Oracle10gDialect</jpaSource.dialect>
<jpaSource.driverClassName>oracle.jdbc.driver.OracleDriver</jpaSource.driverClassName>
<jpaSource.url>jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:qaora11</jpaSource.url>
@@ -633,6 +640,7 @@
</dependency>
</dependencies>
<properties>
+ <database>sybase15</database>
<jpaSource.dialect>org.hibernate.dialect.SybaseDialect</jpaSource.dialect>
<jpaSource.driverClassName>com.sybase.jdbc3.jdbc.SybDriver</jpaSource.driverClassName>
<jpaSource.url>jdbc:sybase:Tds:vmg07.mw.lab.eng.bos.redhat.com:5000/jbossdna</jpaSource.url>
@@ -660,6 +668,8 @@
</dependency>
</dependencies>
<properties>
+ <database>mssql2008</database>
+
<metadata.collectorClassName>org.jboss.dna.connector.meta.jdbc.SqlServerMetadataCollector</metadata.collectorClassName>
<jpaSource.dialect>org.hibernate.dialect.SQLServerDialect</jpaSource.dialect>
<jpaSource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</jpaSource.driverClassName>
<jpaSource.url>jdbc:sqlserver://vmg04.mw.lab.eng.bos.redhat.com</jpaSource.url>