cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r775629 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/dbsync/ test/java/org/apache/cayenne/access/dbsync/ test/resources/
Date Sun, 17 May 2009 11:55:20 GMT
Author: aadamchik
Date: Sun May 17 11:55:19 2009
New Revision: 775629

URL: http://svn.apache.org/viewvc?rev=775629&view=rev
Log:
CAY-1193 Auto load schema on startup

StrategyAnalyzer.txt patch from Olga Tkachova... I did some cleanup and renaming

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SchemaAnalyzer.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/CreateIfNoSchemaStrategy.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SkipSchemaUpdateStrategy.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialOrCreateSchemaStrategy.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialSchemaStrategy.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/sus-map.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java?rev=775629&r1=775628&r2=775629&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
Sun May 17 11:55:19 2009
@@ -27,15 +27,25 @@
  */
 public abstract class BaseSchemaUpdateStrategy implements SchemaUpdateStrategy {
 
-    protected BaseSchemaUpdateStrategy currentSchema;
-
-    protected abstract BaseSchemaUpdateStrategy getSchema();
+    protected volatile boolean run;
 
     /**
      * @since 3.0
      */
-    public void generateUpdateSchema(DataNode dataNode) throws SQLException {
-            getSchema().generateUpdateSchema(dataNode);
-             currentSchema = new SkipSchemaUpdateStrategy();
-     };
+    public void updateSchema(DataNode dataNode) throws SQLException {
+        if(!run) {
+            synchronized(this) {
+              if(!run) {
+                generateUpdateSchema(dataNode);
+                run = true;
+              }
+            }
+         }
+    }
+    
+    /**
+     * @since 3.0
+     */
+    protected abstract void generateUpdateSchema(DataNode dataNode) throws SQLException;
+ 
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/CreateIfNoSchemaStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/CreateIfNoSchemaStrategy.java?rev=775629&r1=775628&r2=775629&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/CreateIfNoSchemaStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/CreateIfNoSchemaStrategy.java
Sun May 17 11:55:19 2009
@@ -42,20 +42,6 @@
     final Log logObj = LogFactory.getLog(CreateIfNoSchemaStrategy.class);
 
     @Override
-    protected BaseSchemaUpdateStrategy getSchema() {
-        return currentSchema;
-    }
-
-    public CreateIfNoSchemaStrategy() {
-        currentSchema = this;
-    }
-
-    public void updateSchema(DataNode dataNode) throws SQLException {
-        super.generateUpdateSchema(dataNode);
-    }
-
-  
-    @Override
     public void generateUpdateSchema(DataNode dataNode) throws SQLException {
 
         Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
@@ -68,16 +54,16 @@
                 break;
             }
         }
+
         if (generate) {
             generate(dataNode);
         }
         else {
-            logObj
-                    .info("DbGenerator no create, because one of the tables, modeled in Cayenne,
already exist in DB");
+            logObj.info("Full or partial schema is present, skipping schema generation");
         }
     }
 
-    private synchronized void generate(DataNode dataNode) {
+    private void generate(DataNode dataNode) {
         Collection<DataMap> map = dataNode.getDataMaps();
         Iterator<DataMap> iterator = map.iterator();
         while (iterator.hasNext()) {

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SchemaAnalyzer.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SchemaAnalyzer.java?rev=775629&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SchemaAnalyzer.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SchemaAnalyzer.java
Sun May 17 11:55:19 2009
@@ -0,0 +1,220 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access.dbsync;
+
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+
+/**
+ * @since 3.0
+ */
+class SchemaAnalyzer {
+
+    private Map<String, String> mapTableInDB;
+    private List<String> tableNoInDB;
+    private Map<String, Collection<String>> nameSchemaMap;
+    private Map<String, Collection<String>> schemaNameMap;
+    private Map<Map<String, String>, Collection<DbAttribute>> entityTables;
+    private String errorMessage;
+
+    SchemaAnalyzer() {
+        errorMessage = null;
+        mapTableInDB = new HashMap<String, String>();
+        tableNoInDB = new ArrayList<String>();
+        nameSchemaMap = new HashMap<String, Collection<String>>();
+        schemaNameMap = new HashMap<String, Collection<String>>();
+        entityTables = new HashMap<Map<String, String>, Collection<DbAttribute>>();
+    }
+
+    public List<String> getTableNoInDB() {
+        return tableNoInDB;
+    }
+
+    public void compareColumns(DatabaseMetaData md) throws SQLException {
+
+        for (Map.Entry<String, String> map : mapTableInDB.entrySet()) {
+
+            String schema = map.getValue();
+            String name = map.getKey();
+
+            ResultSet rs = md.getColumns(null, schema, name, null);
+            try {
+                Map<String, String> schemaName = new HashMap<String, String>();
+                schemaName.put(name, schema);
+                Collection<DbAttribute> atribute = entityTables.get(schemaName);
+                if (atribute == null) {
+                    schemaName.remove(name);
+                    schemaName.put(name, null);
+                    atribute = entityTables.get(schemaName);
+                }
+                if (atribute != null && rs.getFetchSize() != 0) {
+                    int countColumn = 0;
+                    int isInEntity = 0;
+                    while (rs.next()) {
+                        countColumn++;
+                        String columnName = rs.getString("COLUMN_NAME");
+                        for (DbAttribute attr : atribute) {
+
+                            if (attr.getName().equalsIgnoreCase(columnName)) {
+                                isInEntity++;
+                                continue;
+                            }
+                        }
+                    }
+
+                    if (countColumn != atribute.size()) {
+                        errorMessage = "different number of columns in table " + name;
+                        continue;
+                    }
+                    if (countColumn != isInEntity && errorMessage == null) {
+                        errorMessage = "no columns in table "
+                                + name
+                                + " or does not match the type of column";
+                        continue;
+                    }
+
+                }
+            }
+            finally {
+                rs.close();
+            }
+        }
+
+    }
+
+    public boolean compareTables(DatabaseMetaData md, Collection<DbEntity> entities)
{
+
+        boolean isIncluded = true;
+        for (DbEntity ent : entities) {
+
+            String name = ent.getName();
+            String schema = ent.getSchema();
+            Collection<DbAttribute> atributes = ent.getAttributes();
+
+            if (schema != null) {
+                if (schemaNameMap.get(schema) != null) {
+
+                }
+                else {
+                    isIncluded = false;
+                    errorMessage = "no schema " + schema + " in db";
+                    break;
+                }
+            }
+            else {
+                if (nameSchemaMap.get(name) != null
+                        || !ent.getDataMap().isQuotingSQLIdentifiers()
+                        && (nameSchemaMap.get(name.toLowerCase()) != null || nameSchemaMap
+                                .get(name.toUpperCase()) != null)) {
+                    Collection<String> sc = nameSchemaMap.get(name);
+                    if (sc == null) {
+                        if (nameSchemaMap.get(name.toLowerCase()) != null) {
+                            sc = nameSchemaMap.get(name.toLowerCase());
+                        }
+                        else {
+                            sc = nameSchemaMap.get(name.toUpperCase());
+                        }
+                    }
+
+                    if (sc.size() == 1) {
+                        mapTableInDB.put(name, sc.iterator().next());
+                    }
+                    else {
+                        errorMessage = " enter the schema. Table found in the schemas: ";
+                        Iterator<String> it = sc.iterator();
+                        String names = "";
+                        while (it.hasNext()) {
+                            names += it.next() + ", ";
+                        }
+                        errorMessage = errorMessage + names;
+                    }
+                }
+                else {
+                    tableNoInDB.add(name);
+                }
+            }
+            Map<String, String> schemaName = new HashMap<String, String>();
+            schemaName.put(name, schema);
+            entityTables.put(schemaName, atributes);
+        }
+        return isIncluded;
+    }
+
+    public void analyzeSchemas(List<String> schemas, DatabaseMetaData md)
+            throws SQLException {
+
+        if (schemas.size() == 0) {
+            schemas.add("%");
+        }
+        for (String schema : schemas) {
+            ResultSet tables = md.getTables(null, schema, null, null);
+
+            Collection<String> tableInSchema = new ArrayList<String>();
+            try {
+                while (tables.next()) {
+                    String name = tables.getString("TABLE_NAME");
+                    if (name == null || name.startsWith("BIN$")) {
+                        continue;
+                    }
+
+                    tableInSchema.add(name);
+                    if (nameSchemaMap.get(name) != null) {
+                        Collection<String> sc = nameSchemaMap.get(name);
+                        Iterator<String> iSc = sc.iterator();
+                        boolean inSchema = false;
+                        while (iSc.hasNext()) {
+                            if (iSc.next().equals(schema)) {
+                                inSchema = true;
+                            }
+                        }
+                        if (!inSchema) {
+                            sc.add(schema);
+                            nameSchemaMap.remove(name);
+                            nameSchemaMap.put(name, sc);
+                        }
+
+                    }
+                    else {
+                        Collection<String> sc = new ArrayList<String>();
+                        sc.add(schema);
+                        nameSchemaMap.put(name, sc);
+                    }
+                }
+                schemaNameMap.put(schema, tableInSchema);
+            }
+            finally {
+                tables.close();
+            }
+        }
+    }
+
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SkipSchemaUpdateStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SkipSchemaUpdateStrategy.java?rev=775629&r1=775628&r2=775629&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SkipSchemaUpdateStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/SkipSchemaUpdateStrategy.java
Sun May 17 11:55:19 2009
@@ -26,7 +26,7 @@
  * 
  * @since 3.0
  */
-public class SkipSchemaUpdateStrategy extends BaseSchemaUpdateStrategy {
+public class SkipSchemaUpdateStrategy implements SchemaUpdateStrategy {
 
     /**
      * @since 3.0
@@ -34,17 +34,4 @@
     public void updateSchema(DataNode dataNode) {
         // does nothing
     }
-
-    /**
-     * @since 3.0
-     */
-    @Override
-    public void generateUpdateSchema(DataNode dataNode) {
-        // does nothing
-    }
-
-    @Override
-    protected BaseSchemaUpdateStrategy getSchema() {
-        return this;
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialOrCreateSchemaStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialOrCreateSchemaStrategy.java?rev=775629&r1=775628&r2=775629&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialOrCreateSchemaStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialOrCreateSchemaStrategy.java
Sun May 17 11:55:19 2009
@@ -26,25 +26,14 @@
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.DbGenerator;
 import org.apache.cayenne.map.DataMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * @since 3.0
  */
 public class ThrowOnPartialOrCreateSchemaStrategy extends ThrowOnPartialSchemaStrategy {
 
-    final Log logObj = LogFactory.getLog(ThrowOnPartialOrCreateSchemaStrategy.class);
-
-    /**
-     * @since 3.0
-     */
-    public ThrowOnPartialOrCreateSchemaStrategy() {
-        currentSchema = this;
-    }
-
     @Override
-    protected synchronized void analyser(
+    protected void analyze(
             DataNode dataNode,
             List<String> mergerOnlyTable,
             String errorMessage,
@@ -56,7 +45,7 @@
             generate(dataNode);
         }
         else {
-            String err = "Parser schema detected: ";
+            String err = "Partial schema detected: ";
             if (errorMessage != null) {
                 err += errorMessage;
             }
@@ -70,7 +59,7 @@
         }
     }
 
-    private synchronized void generate(DataNode dataNode) {
+    private void generate(DataNode dataNode) {
         Collection<DataMap> map = dataNode.getDataMaps();
         Iterator<DataMap> iterator = map.iterator();
         while (iterator.hasNext()) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialSchemaStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialSchemaStrategy.java?rev=775629&r1=775628&r2=775629&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialSchemaStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/dbsync/ThrowOnPartialSchemaStrategy.java
Sun May 17 11:55:19 2009
@@ -18,86 +18,74 @@
  ****************************************************************/
 package org.apache.cayenne.access.dbsync;
 
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
-
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.merge.DbMerger;
-import org.apache.cayenne.merge.MergerToken;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @since 3.0
  */
 public class ThrowOnPartialSchemaStrategy extends BaseSchemaUpdateStrategy {
 
-    @Override
-    public BaseSchemaUpdateStrategy getSchema() {
-        return currentSchema;
-    }
-
-    /**
-     * @since 3.0
-     */
-    public ThrowOnPartialSchemaStrategy() {
-        currentSchema = this;
-    }
-
-    /**
-     * @throws SQLException 
-     * @since 3.0
-     */
-    public void updateSchema(DataNode dataNode) throws SQLException {
-        super.generateUpdateSchema(dataNode);
-    }
+    final Log log = LogFactory.getLog(ThrowOnPartialSchemaStrategy.class);
 
     /**
      * @since 3.0
      */
     @Override
     public void generateUpdateSchema(DataNode dataNode) {
-        String errorMessage = null;
-        List<String> mergerOnlyTable = new ArrayList<String>();
-        DbMerger merger = new DbMerger();
-        Collection<String> entityNames = new ArrayList<String>();
-        Collection<DbEntity> entities = dataNode.getEntityResolver().getDbEntities();
-        int entitiesSize = entities.size();
-        Iterator<DbEntity> entitiesIterator = entities.iterator();
-        while (entitiesIterator.hasNext()) {
-            entityNames.add(entitiesIterator.next().getName());
-        }
 
-        Collection<DataMap> map = dataNode.getDataMaps();
-        Iterator<DataMap> iterator = map.iterator();
-        while (iterator.hasNext()) {
-            List<MergerToken> mergerTokens = merger.createMergeTokens(dataNode
-                    .getAdapter(), dataNode.getDataSource(), iterator.next());
-            Iterator<MergerToken> tokensIt = mergerTokens.iterator();
-            while (tokensIt.hasNext()) {
-                MergerToken token = tokensIt.next();
-                if (entityNames.contains(token.getTokenValue())
-                        && !token.getTokenName().equals("Drop Table")) {
-                    if (token.getTokenName().equals("Create Table")) {
-                        mergerOnlyTable.add(token.getTokenValue());
-                    }
-                    else {
-                        errorMessage = token.getTokenName()
-                                + " in table "
-                                + token.getTokenValue();
-                        break;
-                    }
+        SchemaAnalyzer analyzer = new SchemaAnalyzer();
+
+        List<String> schemas = new ArrayList<String>();
+        DatabaseMetaData md = null;
+        try {
+            Connection connection = dataNode.getDataSource().getConnection();
+            md = connection.getMetaData();
+            ResultSet rs = md.getSchemas();
+
+            try {
+                while (rs.next()) {
+                    String schema_name = rs.getString(1);
+                    schemas.add(schema_name);
                 }
             }
+            finally {
+                rs.close();
+            }
+            connection.close();
+            analyzer.analyzeSchemas(schemas, md);
+        }
+        catch (Exception e) {
+            log.debug("Exception analyzing schema, ignoring", e);
+        }
+
+        Collection<DbEntity> entities = dataNode.getEntityResolver().getDbEntities();
+
+        boolean isIncluded = analyzer.compareTables(md, entities);
+
+        if (isIncluded && analyzer.getErrorMessage() == null) {
+            try {
+                analyzer.compareColumns(md);
+            }
+            catch (SQLException e) {
+                log.debug("Exception analyzing schema, ignoring", e);
+            }
         }
-        analyser(dataNode, mergerOnlyTable, errorMessage, entitiesSize);
+        analyze(dataNode, analyzer.getTableNoInDB(), analyzer.getErrorMessage(), entities
+                .size());
     }
 
-    protected synchronized void analyser(
+    protected void analyze(
             DataNode dataNode,
             List<String> mergerOnlyTable,
             String errorMessage,
@@ -106,7 +94,7 @@
         if (mergerOnlyTable.size() == 0 && errorMessage == null) {
         }
         else {
-            String err = "Parser schema detected: ";
+            String err = "Partial schema detected: ";
             if (errorMessage != null) {
                 err += errorMessage;
             }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java?rev=775629&r1=775628&r2=775629&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
Sun May 17 11:55:19 2009
@@ -140,7 +140,7 @@
         try {
             dataNode.performQueries(Collections.singletonList((Query) query), observer);
             Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
-            assertNotNull(nameTables.get("SUS1"));
+            assertTrue(nameTables.get("sus1")!=null || nameTables.get("SUS1")!=null );
             int sizeDB2 = getNameTablesInDB(dataNode).size();
             assertEquals(2, sizeDB2 - sizeDB);
             dataNode.performQueries(Collections.singletonList((Query) query), observer);
@@ -245,7 +245,6 @@
             DataNode dataNode2 = createDataNode(map);
             setStrategy(strategy, dataNode2);
             dataNode2.performQueries(Collections.singletonList((Query) query), observer);
-            dataNode2.performQueries(Collections.singletonList((Query) query), observer);
         }
         finally {
             dropTables(map, dataNode, observer);
@@ -291,7 +290,8 @@
 
         dataNode.performQueries(Collections.singletonList((Query) query), observer);
         Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
-        assertNotNull(nameTables.get("SUS1"));
+        assertTrue(nameTables.get("sus1") != null || nameTables.get("SUS1") != null);
+
     }
 
     private void setStrategy(String name, DataNode dataNode) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/sus-map.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/sus-map.map.xml?rev=775629&r1=775628&r2=775629&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/sus-map.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/sus-map.map.xml
Sun May 17 11:55:19 2009
@@ -5,6 +5,10 @@
 	project-version="3.0">
 	<db-entity name="SUS1">
 		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="strNoMandatory" type="VARCHAR" length="200"/>
+		<db-attribute name="testBoolean" type="BOOLEAN" isMandatory="true"/>
+		<db-attribute name="testChar" type="CHAR" isMandatory="true" length="200"/>
+		<db-attribute name="testString" type="VARCHAR" isMandatory="true" length="200"/>
 	</db-entity>
 	<db-entity name="SUS2">
 		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>



Mime
View raw message