summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-07 09:31:57 (EDT)
committerEike Stepper2008-04-07 09:31:57 (EDT)
commitc763cd5ffa9f5941b09478c47cf836ecfcd43627 (patch)
tree641c1213e51b6655fa347e58ef07486b40071d86
parent1291bf4e3c6c1ba54e066925929e2929479e92dc (diff)
downloadcdo-c763cd5ffa9f5941b09478c47cf836ecfcd43627.zip
cdo-c763cd5ffa9f5941b09478c47cf836ecfcd43627.tar.gz
cdo-c763cd5ffa9f5941b09478c47cf836ecfcd43627.tar.bz2
[222974] [CDO] DanglingHREFException after putEPackage() when using referencing models
https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java65
2 files changed, 67 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 328b3c3..8b62279 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -101,16 +101,19 @@ public class DBStore extends LongIDStore implements IDBStore
return dbConnectionProvider;
}
+ @Override
public boolean hasAuditingSupport()
{
return true;
}
+ @Override
public boolean hasBranchingSupport()
{
return false;
}
+ @Override
public boolean hasWriteDeltaSupport()
{
return false;
@@ -292,6 +295,7 @@ public class DBStore extends LongIDStore implements IDBStore
}
}
+ @Override
public void repairAfterCrash()
{
Repository repository = (Repository)getRepository();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index 97180bd..83c2903 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -23,10 +23,13 @@ import javax.sql.DataSource;
import java.sql.Clob;
import java.sql.Connection;
+import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import java.util.Map;
/**
@@ -119,7 +122,11 @@ public final class DBUtil
{
try
{
- resultSet.getStatement().setMaxRows(0);
+ Statement statement = resultSet.getStatement();
+ if (statement != null)
+ {
+ statement.setMaxRows(0);
+ }
}
catch (Exception ex)
{
@@ -140,6 +147,57 @@ public final class DBUtil
return null;
}
+ public static List<String> getAllTableNames(Connection connection, String dbName)
+ {
+ ResultSet tables = null;
+
+ try
+ {
+ List<String> names = new ArrayList<String>();
+ DatabaseMetaData metaData = connection.getMetaData();
+ tables = metaData.getTables(dbName, null, null, new String[] { "TABLE" });
+ while (tables.next())
+ {
+ String name = tables.getString(3);
+ names.add(name);
+ }
+
+ return names;
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ close(tables);
+ }
+ }
+
+ public static void dropAllTables(Connection connection, String dbName)
+ {
+ Statement statement = null;
+
+ try
+ {
+ statement = connection.createStatement();
+ for (String tableName : DBUtil.getAllTableNames(connection, dbName))
+ {
+ String sql = "DROP TABLE " + tableName;
+ DBUtil.trace(sql);
+ statement.execute(sql);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ DBUtil.close(statement);
+ }
+ }
+
public static int selectMaximumInt(Connection connection, IDBField field) throws DBException
{
Number number = getMaximumNumber(connection, field);
@@ -383,6 +441,9 @@ public final class DBUtil
public static void trace(String sql)
{
- if (TRACER.isEnabled()) TRACER.trace(sql);
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(sql);
+ }
}
}