Browse files

CMP-363 ability to specify schema in db2

  • Loading branch information...
1 parent b2280af commit ea976ce22f310d4a75231675ff37c3fca4cf9f69 @kimchy committed Mar 4, 2010
View
7 .classpath
@@ -99,5 +99,12 @@
<classpathentry kind="lib" path="lib/jackson/jackson-mapper-asl-1.4.0.jar"/>
<classpathentry kind="lib" path="lib/openejb/openejb-core-3.1.jar"/>
<classpathentry kind="lib" path="lib/terracotta/tim-concurrent-collections-1.0.2.jar"/>
+ <classpathentry kind="lib" path="lib/datanucleus/datanucleus-core-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/datanucleus/datanucleus-jpa-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/jdo/jdo2-api-2.3-SNAPSHOT.jar"/>
+ <classpathentry kind="lib" path="lib/gae/appengine-api.jar"/>
+ <classpathentry kind="lib" path="lib/gae/appengine-api-labs.jar"/>
+ <classpathentry kind="lib" path="lib/gae/appengine-api-stubs.jar"/>
+ <classpathentry kind="lib" path="lib/gae/appengine-local-runtime.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
View
30 src/main/src/org/apache/lucene/store/jdbc/JdbcDirectorySettings.java
@@ -76,6 +76,12 @@
private Class lockClass = PhantomReadLock.class;
+ private String tableCatalog = null;
+
+ private String tableSchema = null;
+
+ private String tableType = "";
+
/**
* Creates a new instance of the Jdbc directory settings with it's default values initialized.
*/
@@ -302,4 +308,28 @@ public Class getLockClass() {
public void setLockClass(Class lockClass) {
this.lockClass = lockClass;
}
+
+ public String getTableCatalog() {
+ return tableCatalog;
+ }
+
+ public void setTableCatalog(String tableCatalog) {
+ this.tableCatalog = tableCatalog;
+ }
+
+ public String getTableSchema() {
+ return tableSchema;
+ }
+
+ public void setTableSchema(String tableSchema) {
+ this.tableSchema = tableSchema;
+ }
+
+ public String getTableType() {
+ return tableType;
+ }
+
+ public void setTableType(String tableType) {
+ this.tableType = tableType;
+ }
}
View
2 src/main/src/org/apache/lucene/store/jdbc/dialect/DialectResolver.java
@@ -107,6 +107,8 @@ public DialectResolver(boolean useDefaultMappers) {
}
mappers.add(new DatabaseNameToDialectMapper("HSQL Database Engine", HSQLDialect.class));
mappers.add(new DatabaseNameToDialectMapper("DB2/NT", DB2Dialect.class));
+ mappers.add(new DatabaseNameToDialectMapper("DB2/LINUX", DB2Dialect.class));
+ mappers.add(new DatabaseNameToDialectMapper("DB2/LINUXX8664", DB2Dialect.class));
mappers.add(new DatabaseNameToDialectMapper("MySQL", MySQLDialect.class));
mappers.add(new DatabaseNameToDialectMapper("PostgreSQL", PostgreSQLDialect.class));
mappers.add(new DatabaseNameStartsWithToDialectMapper("Microsoft SQL Server", SQLServerDialect.class));
View
12 src/main/src/org/apache/lucene/store/jdbc/support/JdbcTable.java
@@ -66,7 +66,7 @@
private JdbcColumn deletedColumn;
public JdbcTable(JdbcDirectorySettings settings, Dialect dialect, String name) {
- this(settings, dialect, name, null, null);
+ this(settings, dialect, name, settings.getTableCatalog(), settings.getTableSchema());
}
public JdbcTable(JdbcDirectorySettings settings, Dialect dialect, String name, String catalog, String schema) {
@@ -90,7 +90,7 @@ public JdbcTable(JdbcDirectorySettings settings, Dialect dialect, String name, S
.append(lastModifiedColumn.getName()).append(' ').append(lastModifiedColumn.getType()).append(" , ")
.append(deletedColumn.getName()).append(' ').append(deletedColumn.getType())
.append(", " + "primary key (").append(nameColumn.getName()).append(") ) ")
- .append(dialect.getTableTypeString()).toString();
+ .append(getTableTypeString(dialect)).toString();
sb.setLength(0);
sb.append("drop table ");
@@ -179,6 +179,14 @@ public JdbcTable(JdbcDirectorySettings settings, Dialect dialect, String name, S
.toString();
}
+ private String getTableTypeString(Dialect dialect) {
+ String tableType = settings.getTableType();
+
+ if (tableType == null || tableType.length() == 0)
+ tableType = dialect.getTableTypeString();
+ return tableType;
+ }
+
public void setName(String name) {
if (name.charAt(0) == dialect.openQuote()) {
quoted = true;
View
15 src/main/src/org/compass/core/lucene/LuceneEnvironment.java
@@ -1228,6 +1228,21 @@
* The name of the deleted column. Defaults to deleted_.
*/
public static final String DELETED_NAME = "compass.engine.store.jdbc.ddl.deleted.name";
+
+ /**
+ * The name of the database catalog. Defaults to null.
+ */
+ public static final String TABLE_CATALOG = "compass.engine.store.jdbc.ddl.table.catalog";
+
+ /**
+ * The name of the database schema. Defaults to null.
+ */
+ public static final String TABLE_SCHEME = "compass.engine.store.jdbc.ddl.table.schema";
+
+ /**
+ * The table type for database dialect. Defaults to "".
+ */
+ public static final String TABLE_TYPE = "compass.engine.store.jdbc.ddl.table.type";
}
public abstract class FileEntry {
View
4 src/main/src/org/compass/core/lucene/engine/store/JdbcDirectoryStore.java
@@ -141,6 +141,10 @@ public void configure(CompassSettings settings) throws CompassException {
jdbcSettings.setNameColumnLength(settings.getSettingAsInt(LuceneEnvironment.JdbcStore.DDL.NAME_LENGTH, jdbcSettings.getNameColumnLength()));
jdbcSettings.setValueColumnLengthInK(settings.getSettingAsInt(LuceneEnvironment.JdbcStore.DDL.VALUE_LENGTH, jdbcSettings.getValueColumnLengthInK()));
+ jdbcSettings.setTableCatalog(settings.getSetting(LuceneEnvironment.JdbcStore.DDL.TABLE_CATALOG, jdbcSettings.getTableCatalog()));
+ jdbcSettings.setTableSchema(settings.getSetting(LuceneEnvironment.JdbcStore.DDL.TABLE_SCHEME, jdbcSettings.getTableSchema()));
+ jdbcSettings.setTableType(settings.getSetting(LuceneEnvironment.JdbcStore.DDL.TABLE_TYPE, jdbcSettings.getTableType()));
+
jdbcSettings.setDeleteMarkDeletedDelta(settings.getSettingAsLong(LuceneEnvironment.JdbcStore.DELETE_MARK_DELETED_DELTA, jdbcSettings.getDeleteMarkDeletedDelta()));
if (log.isDebugEnabled()) {
log.debug("Using delete mark deleted older than [" + jdbcSettings.getDeleteMarkDeletedDelta() + "ms]");
View
4 src/main/src/org/compass/gps/device/jdbc/dialect/DialectResolver.java
@@ -107,6 +107,8 @@ public DialectResolver(boolean useDefaultMappers) {
}
mappers.add(new DatabaseNameToDialectMapper("HSQL Database Engine", DefaultJdbcDialect.class));
mappers.add(new DatabaseNameToDialectMapper("DB2/NT", DefaultJdbcDialect.class));
+ mappers.add(new DatabaseNameToDialectMapper("DB2/LINUX", DefaultJdbcDialect.class));
+ mappers.add(new DatabaseNameToDialectMapper("DB2/LINUXX8664", DefaultJdbcDialect.class));
mappers.add(new DatabaseNameToDialectMapper("MySQL", DefaultJdbcDialect.class));
mappers.add(new DatabaseNameToDialectMapper("PostgreSQL", DefaultJdbcDialect.class));
mappers.add(new DatabaseNameStartsWithToDialectMapper("Microsoft SQL Server", DefaultJdbcDialect.class));
@@ -151,4 +153,4 @@ public JdbcDialect getDialect(DataSource dataSource) throws JdbcStoreException {
throw new JdbcStoreException("Failed to auto detect dialect, no match found for database [" + databaseName +
"] version [" + databaseMajorVersion + "/" + databaseMinorVersion + "] driver [" + driverName + "]");
}
-}
+}

0 comments on commit ea976ce

Please sign in to comment.