diff options
author | bvosburgh | 2011-03-03 00:16:35 +0000 |
---|---|---|
committer | bvosburgh | 2011-03-03 00:16:35 +0000 |
commit | 3fbe8e1bc8a2d6c380fdf6c132a275816c25bc9f (patch) | |
tree | 2ab47617872c656731181ede68e17bbc99fd0d11 /jpa | |
parent | d1d8d17013021d9b62e26cfd5a1bb14586652c5a (diff) | |
download | webtools.dali-3fbe8e1bc8a2d6c380fdf6c132a275816c25bc9f.tar.gz webtools.dali-3fbe8e1bc8a2d6c380fdf6c132a275816c25bc9f.tar.xz webtools.dali-3fbe8e1bc8a2d6c380fdf6c132a275816c25bc9f.zip |
[334454] rework database stuff to handle MySQL case-sensitivity craziness
Diffstat (limited to 'jpa')
6 files changed, 35 insertions, 30 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaDataSource.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaDataSource.java index 77a241b96f..aa2699ac83 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaDataSource.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaDataSource.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,7 @@ package org.eclipse.jpt.jpa.core; import org.eclipse.jpt.jpa.db.ConnectionProfile; import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.DatabaseObject; +import org.eclipse.jpt.jpa.db.Table; /** * Interface to the connection profile. @@ -69,9 +69,9 @@ public interface JpaDataSource Database getDatabase(); /** - * Select and return the database object with the specified identifier. + * Select and return the table with the specified identifier. */ - <T extends DatabaseObject> T selectDatabaseObjectForIdentifier(Iterable<T> databaseObjects, String identifier); + Table selectTableForIdentifier(Iterable<Table> tables, String identifier); /** * Dispose the data source. diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JptJpaCorePlugin.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JptJpaCorePlugin.java index 5615ba87f1..b402aa2b85 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JptJpaCorePlugin.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JptJpaCorePlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * Copyright (c) 2006, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -691,26 +691,33 @@ public class JptJpaCorePlugin } /** - * Log the specified status. - */ - public static void log(IStatus status) { - INSTANCE.getLog().log(status); - } - - /** * Log the specified message. */ public static void log(String msg) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, null)); + log(msg, null); } /** * Log the specified exception or error. */ public static void log(Throwable throwable) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, throwable.getLocalizedMessage(), throwable)); + log(throwable.getLocalizedMessage(), throwable); + } + + /** + * Log the specified message and exception or error. + */ + public static void log(String msg, Throwable throwable) { + log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, throwable)); } + /** + * Log the specified status. + */ + public static void log(IStatus status) { + INSTANCE.getLog().log(status); + } + // ********** plug-in implementation ********** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java index 64aa721acf..b1cd5965aa 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java @@ -1078,7 +1078,7 @@ public abstract class AbstractJavaEntity @Override public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { // matching database objects and identifiers is database platform-specific - return this.getDataSource().selectDatabaseObjectForIdentifier(this.getAllAssociatedDbTables(), tableName); + return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName); } /** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java index f3962106dd..0ee68c07dd 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java @@ -1514,7 +1514,7 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> @Override public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { // matching database objects and identifiers is database platform-specific - return this.getDataSource().selectDatabaseObjectForIdentifier(this.getAllAssociatedDbTables(), tableName); + return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName); } /** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java index f7f658d9e6..e8e2168fe6 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -20,7 +20,7 @@ import org.eclipse.jpt.jpa.db.ConnectionProfileFactory; import org.eclipse.jpt.jpa.db.ConnectionProfileListener; import org.eclipse.jpt.jpa.db.Database; import org.eclipse.jpt.jpa.db.DatabaseIdentifierAdapter; -import org.eclipse.jpt.jpa.db.DatabaseObject; +import org.eclipse.jpt.jpa.db.Table; /** * GenericJpaDataSource @@ -117,9 +117,9 @@ public class GenericJpaDataSource return (cp == null) ? null : cp.getDatabase(); } - public <T extends DatabaseObject> T selectDatabaseObjectForIdentifier(Iterable<T> databaseObjects, String identifier) { + public Table selectTableForIdentifier(Iterable<Table> tables, String identifier) { Database db = this.getDatabase(); - return (db == null) ? null : db.selectDatabaseObjectForIdentifier(databaseObjects, identifier); + return (db == null) ? null : db.selectTableForIdentifier(tables, identifier); } public void dispose() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaDatabaseIdentifierAdapter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaDatabaseIdentifierAdapter.java index 7556b60b23..12e19f3689 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaDatabaseIdentifierAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/GenericJpaDatabaseIdentifierAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * Copyright (c) 2009, 2011 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,6 +11,7 @@ package org.eclipse.jpt.jpa.core.internal.jpa2; import java.util.Iterator; +import org.eclipse.jpt.common.utility.internal.StringTools; import org.eclipse.jpt.jpa.core.JpaDataSource; import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; import org.eclipse.jpt.jpa.core.context.persistence.Persistence; @@ -38,15 +39,8 @@ public class GenericJpaDatabaseIdentifierAdapter /** * If the flag is set, "identifiers" are treated as "names". */ - public String convertIdentifierToName(String identifier, DefaultCallback defaultCallback) { - return this.getDefaultDelimitedIdentifiers() ? identifier : defaultCallback.convertIdentifierToName(identifier); - } - - /** - * If the flag is set, "names" are treated as "identifiers". - */ - public String convertNameToIdentifier(String name, DefaultCallback defaultCallback) { - return this.getDefaultDelimitedIdentifiers() ? name : defaultCallback.convertNameToIdentifier(name); + public boolean treatIdentifiersAsDelimited() { + return this.getDefaultDelimitedIdentifiers(); } protected boolean getDefaultDelimitedIdentifiers() { @@ -77,4 +71,8 @@ public class GenericJpaDatabaseIdentifierAdapter return (rcn == null) ? null : rcn.getPersistenceXml(); } + @Override + public String toString() { + return StringTools.buildToStringFor(this, Boolean.valueOf(this.treatIdentifiersAsDelimited())); + } } |