cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r740245 [2/2] - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/caye...
Date Tue, 03 Feb 2009 08:29:06 GMT
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCase.java?rev=740245&r1=740244&r2=740245&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCase.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCase.java
Tue Feb  3 08:29:04 2009
@@ -17,7 +17,6 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.access;
 
 import java.sql.Connection;
@@ -32,8 +31,6 @@
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneCase;
 
-/**
- */
 public abstract class DataContextCase extends CayenneCase {
 
     public static final int artistCount = 25;
@@ -52,10 +49,9 @@
     }
 
     protected Painting fetchPainting(String name, boolean prefetchArtist) {
-        SelectQuery select =
-            new SelectQuery(
-                Painting.class,
-                ExpressionFactory.matchExp("paintingTitle", name));
+        SelectQuery select = new SelectQuery(Painting.class, ExpressionFactory.matchExp(
+                "paintingTitle",
+                name));
         if (prefetchArtist) {
             select.addPrefetch("toArtist");
         }
@@ -65,8 +61,9 @@
     }
 
     protected Artist fetchArtist(String name, boolean prefetchPaintings) {
-        SelectQuery q =
-            new SelectQuery(Artist.class, ExpressionFactory.matchExp("artistName", name));
+        SelectQuery q = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
+                "artistName",
+                name));
         if (prefetchPaintings) {
             q.addPrefetch("paintingArray");
         }
@@ -75,21 +72,19 @@
     }
 
     protected ROArtist fetchROArtist(String name) {
-        SelectQuery q =
-            new SelectQuery(
-                ROArtist.class,
-                ExpressionFactory.matchExp("artistName", name));
+        SelectQuery q = new SelectQuery(ROArtist.class, ExpressionFactory.matchExp(
+                "artistName",
+                name));
         List ats = context.performQuery(q);
         return (ats.size() > 0) ? (ROArtist) ats.get(0) : null;
     }
 
     /**
-     * Temporary workaround for current inability to store dates in test 
-     * fixture XML files.
+     * Temporary workaround for current inability to store dates in test fixture XML
+     * files.
      */
     public void populateExhibits() throws Exception {
-        String insertPaint =
-            "INSERT INTO EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE) VALUES
(?, ?, ?, ?)";
+        String insertPaint = "INSERT INTO EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE,
CLOSING_DATE) VALUES (?, ?, ?, ?)";
 
         Connection conn = getConnection();
 
@@ -116,10 +111,9 @@
     }
 
     /**
-     * Helper method that takes one of the artists from the standard
-     * dataset (always the same one) and creates a new painting for this artist,
-     * committing it to the database. Both Painting and Artist will be cached in current
-     * DataContext.
+     * Helper method that takes one of the artists from the standard dataset (always the
+     * same one) and creates a new painting for this artist, committing it to the
+     * database. Both Painting and Artist will be cached in current DataContext.
      */
     protected Painting insertPaintingInContext(String paintingName) {
         Painting painting = (Painting) context.newObject("Painting");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java?rev=740245&r1=740244&r2=740245&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/SelectTranslatorTest.java
Tue Feb  3 08:29:04 2009
@@ -29,6 +29,7 @@
 import org.apache.art.CompoundPainting;
 import org.apache.art.Painting;
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
+import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionException;
 import org.apache.cayenne.exp.ExpressionFactory;
@@ -333,7 +334,7 @@
 
                 int i2 = sql.indexOf("FROM");
                 assertTrue(sql, i2 > 0);
-                
+
                 assertTrue(sql, sql.indexOf("PAINTING_ID") > 0);
 
                 // assert we have one join
@@ -421,6 +422,472 @@
         test.test(q);
     }
 
+    public void testCreateSqlStringWithQuoteSqlIdentifiers() throws Exception {
+
+        try {
+            SelectQuery q = new SelectQuery(Artist.class);
+            DbEntity entity = getDbEntity("ARTIST");
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+            q.addOrdering("dateOfBirth", Ordering.ASC);
+
+            Template test = new Template() {
+
+                @Override
+                void test(SelectTranslator transl) throws Exception {
+                    JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter()
+                            .getAdapter();
+                    String charStart = adapter.getIdentifiersStartQuote();
+                    String charEnd = adapter.getIdentifiersEndQuote();
+
+                    String query = "SELECT "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_NAME"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "DATE_OF_BIRTH"
+                            + charEnd
+                            + " FROM "
+                            + charStart
+                            + "ARTIST"
+                            + charEnd
+                            + " "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + " ORDER BY "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "DATE_OF_BIRTH"
+                            + charEnd;
+
+                    String s = transl.createSqlString();
+                    assertEquals(query, s);
+                }
+            };
+
+            test.test(q);
+        }
+        finally {
+            DbEntity entity = getDbEntity("ARTIST");
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+
+    }
+
+    public void testCreateSqlStringWithQuoteSqlIdentifiers2() throws Exception {
+
+        try {
+            SelectQuery q = new SelectQuery(Artist.class);
+            DbEntity entity = getDbEntity("ARTIST");
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+            q.setQualifier(ExpressionFactory.greaterExp("dateOfBirth", new Date()));
+            q.andQualifier(ExpressionFactory.lessExp("dateOfBirth", new Date()));
+
+            Template test = new Template() {
+
+                @Override
+                void test(SelectTranslator transl) throws Exception {
+
+                    JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter()
+                            .getAdapter();
+                    String charStart = adapter.getIdentifiersStartQuote();
+                    String charEnd = adapter.getIdentifiersEndQuote();
+
+                    String query = "SELECT "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_NAME"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "DATE_OF_BIRTH"
+                            + charEnd
+                            + " FROM "
+                            + charStart
+                            + "ARTIST"
+                            + charEnd
+                            + " "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + " WHERE ("
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "DATE_OF_BIRTH"
+                            + charEnd
+                            + " > ?) AND ("
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "DATE_OF_BIRTH"
+                            + charEnd
+                            + " < ?)";
+                    String s = transl.createSqlString();
+                    assertEquals(query, s);
+                }
+            };
+
+            test.test(q);
+        }
+        finally {
+            DbEntity entity = getDbEntity("ARTIST");
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+    }
+
+    public void testCreateSqlStringWithQuoteSqlIdentifiers3() throws Exception {
+
+        // query with joint prefetches and other joins
+        // and with QuoteSqlIdentifiers = true
+        try {
+            SelectQuery q = new SelectQuery(Artist.class, Expression
+                    .fromString("paintingArray.paintingTitle = 'a'"));
+            q.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY).setSemantics(
+                    PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
+
+            DbEntity entity = getDbEntity("ARTIST");
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+
+            Template test = new Template() {
+
+                @Override
+                void test(SelectTranslator transl) throws Exception {
+                    JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter()
+                            .getAdapter();
+                    String charStart = adapter.getIdentifiersStartQuote();
+                    String charEnd = adapter.getIdentifiersEndQuote();
+
+                    String query = "SELECT DISTINCT "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_NAME"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "DATE_OF_BIRTH"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ESTIMATED_PRICE"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "PAINTING_DESCRIPTION"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "PAINTING_TITLE"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "GALLERY_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "PAINTING_ID"
+                            + charEnd
+                            + " FROM "
+                            + charStart
+                            + "ARTIST"
+                            + charEnd
+                            + " "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + " LEFT JOIN "
+                            + charStart
+                            + "PAINTING"
+                            + charEnd
+                            + " "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + " ON ("
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + " = "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ") JOIN "
+                            + charStart
+                            + "PAINTING"
+                            + charEnd
+                            + " "
+                            + charStart
+                            + "t2"
+                            + charEnd
+                            + " ON ("
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + " = "
+                            + charStart
+                            + "t2"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ") WHERE "
+                            + charStart
+                            + "t2"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "PAINTING_TITLE"
+                            + charEnd
+                            + " = ?";
+                    String s = transl.createSqlString();
+
+                    assertEquals(query, s);
+                }
+            };
+
+            test.test(q);
+        }
+        finally {
+            DbEntity entity = getDbEntity("ARTIST");
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+    }
+
+    public void testCreateSqlStringWithQuoteSqlIdentifiers4() throws Exception {
+
+        // query with to-one joint prefetches
+        // and with QuoteSqlIdentifiers = true
+        try {
+            SelectQuery q = new SelectQuery(Painting.class);
+            q.addPrefetch(Painting.TO_ARTIST_PROPERTY).setSemantics(
+                    PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
+
+            DbEntity entity = getDbEntity("PAINTING");
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+
+            Template test = new Template() {
+
+                @Override
+                void test(SelectTranslator transl) throws Exception {
+                    JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter()
+                            .getAdapter();
+                    String charStart = adapter.getIdentifiersStartQuote();
+                    String charEnd = adapter.getIdentifiersEndQuote();
+
+                    String query = "SELECT "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "PAINTING_TITLE"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "PAINTING_DESCRIPTION"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ESTIMATED_PRICE"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "GALLERY_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "PAINTING_ID"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_NAME"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "DATE_OF_BIRTH"
+                            + charEnd
+                            + ", "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + " FROM "
+                            + charStart
+                            + "PAINTING"
+                            + charEnd
+                            + " "
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + " LEFT JOIN "
+                            + charStart
+                            + "ARTIST"
+                            + charEnd
+                            + " "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + " ON ("
+                            + charStart
+                            + "t0"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + " = "
+                            + charStart
+                            + "t1"
+                            + charEnd
+                            + "."
+                            + charStart
+                            + "ARTIST_ID"
+                            + charEnd
+                            + ")";
+                    String s = transl.createSqlString();
+
+                    assertEquals(s, query);
+                }
+            };
+
+            test.test(q);
+        }
+        finally {
+            DbEntity entity = getDbEntity("PAINTING");
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+    }
+
     /**
      * Tests columns generated for a simple object query.
      */

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java?rev=740245&r1=740244&r2=740245&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java
Tue Feb  3 08:29:04 2009
@@ -21,7 +21,13 @@
 
 import java.sql.Types;
 
+import org.apache.cayenne.dba.mysql.MySQLAdapter;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbKeyGenerator;
 import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.MySQLStackAdapter;
 
 public class JdbcAdapterTest extends CayenneCase {
 
@@ -46,4 +52,27 @@
         assertEquals(1, types.length);
         assertEquals(TypesMapping.getSqlNameByType(type), types[0]);
     }
+    
+    public void testCreateTableQuoteSqlIdentifiers() {
+         
+        DbEntity entity = new DbEntity();
+        DbAttribute attr = new DbAttribute();
+        attr.setName("name column");
+        attr.setType(1);
+        entity.addAttribute(attr);
+        
+        DbKeyGenerator id = new DbKeyGenerator();
+        entity.setPrimaryKeyGenerator(id);
+        
+        DataMap dm = new DataMap();        
+        dm.setQuotingSQLIdentifiers(true);
+        entity.setDataMap(dm);
+        entity.setName("name table");
+ 
+        if(getAccessStackAdapter().getAdapter() instanceof MySQLAdapter){
+            MySQLAdapter adaptMySQL = (MySQLAdapter) getAccessStackAdapter().getAdapter();
            
+            String str = "CREATE TABLE `name table` (`name column` CHAR NULL) ENGINE=InnoDB";
           
+            assertEquals(str, adaptMySQL.createTable(entity));
+        }
+     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java?rev=740245&r1=740244&r2=740245&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
Tue Feb  3 08:29:04 2009
@@ -145,5 +145,11 @@
 
     public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
     }
-
+    
+    public String getIdentifiersStartQuote(){
+        return "\"";
+    }
+    public String getIdentifiersEndQuote(){
+        return "\"";
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DataMapTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DataMapTest.java?rev=740245&r1=740244&r2=740245&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DataMapTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/DataMapTest.java
Tue Feb  3 08:29:04 2009
@@ -19,6 +19,8 @@
 
 package org.apache.cayenne.map;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -26,11 +28,13 @@
 import junit.framework.TestCase;
 
 import org.apache.cayenne.project.NamedObjectFactory;
+import org.apache.cayenne.project.Project;
 import org.apache.cayenne.query.AbstractQuery;
 import org.apache.cayenne.query.MockAbstractQuery;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.remote.hessian.service.HessianUtil;
 import org.apache.cayenne.util.Util;
+import org.apache.cayenne.util.XMLEncoder;
 
 /**
  * DataMap unit tests.
@@ -398,5 +402,33 @@
             assertEquals(expectedNames[i], proc.getName());
         }
     }
+    
 
+    public void testQuoteSqlIdentifiersEcodeAsXML(){
+        DataMap map = new DataMap("aaa");
+        map.setQuotingSQLIdentifiers(true);  
+        StringWriter w = new StringWriter();
+        XMLEncoder e = new XMLEncoder(new PrintWriter(w));
+        
+        StringBuffer s = new StringBuffer("<data-map project-version=\"");
+        s.append(String.valueOf(Project.CURRENT_PROJECT_VERSION));  
+        s.append("\">\n");     
+        s.append("<property name=\"quoteSqlIdentifiers\" value=\"true\"/>\n");    
 
+        s.append("</data-map>\n");
+        
+        map.encodeAsXML(e);
+        assertEquals(w.getBuffer().toString(), s.toString());  
+        
+        map.setQuotingSQLIdentifiers(false); 
+        StringWriter w2 = new StringWriter();
+        XMLEncoder e2 = new XMLEncoder(new PrintWriter(w2));
+        
+        StringBuffer s2 = new StringBuffer("<data-map project-version=\"");
+        s2.append(String.valueOf(Project.CURRENT_PROJECT_VERSION)); 
+        s2.append("\">\n");          
+        s2.append("</data-map>\n");        
+        map.encodeAsXML(e2);
+        assertEquals(w2.getBuffer().toString(), s2.toString());  
+        
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java?rev=740245&r1=740244&r2=740245&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
Tue Feb  3 08:29:04 2009
@@ -46,11 +46,10 @@
 
 /**
  * Defines a set of algorithms useful for a generic AccessStack.
- * 
  */
 public abstract class AbstractAccessStack {
 
-    private static Log logObj = LogFactory.getLog(AbstractAccessStack.class);
+    private static Log logger = LogFactory.getLog(AbstractAccessStack.class);
 
     // hardcoded dependent entities that should be excluded
     // if LOBs are not supported
@@ -203,11 +202,11 @@
 
                 for (String dropSql : node.getAdapter().dropTableStatements(ent)) {
                     try {
-                        logObj.info(dropSql);
+                        logger.info(dropSql);
                         stmt.execute(dropSql);
                     }
                     catch (SQLException sqe) {
-                        logObj.warn(
+                        logger.warn(
                                 "Can't drop table " + ent.getName() + ", ignoring...",
                                 sqe);
                     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java?rev=740245&r1=740244&r2=740245&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
Tue Feb  3 08:29:04 2009
@@ -23,7 +23,6 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.Arrays;
-import java.util.Iterator;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JButton;
@@ -71,10 +70,11 @@
     protected TextAdapter name;
     protected JLabel location;
     protected JComboBox nodeSelector;
+    protected JCheckBox defaultLockType;
     protected TextAdapter defaultSchema;
     protected TextAdapter defaultPackage;
     protected TextAdapter defaultSuperclass;
-    protected JCheckBox defaultLockType;
+    protected JCheckBox quoteSQLIdentifiers;
 
     protected JButton updateDefaultSchema;
     protected JButton updateDefaultPackage;
@@ -117,6 +117,8 @@
                 setDefaultSchema(text);
             }
         };
+        
+        quoteSQLIdentifiers = new JCheckBox();
 
         updateDefaultPackage = new JButton("Update...");
         defaultPackage = new TextAdapter(new JTextField()) {
@@ -165,6 +167,7 @@
         builder.append("DataMap Name:", name.getComponent(), 3);
         builder.append("File:", location, 3);
         builder.append("DataNode:", nodeSelector, 3);
+        builder.append("Quote SQL Identifiers:", quoteSQLIdentifiers, 3);
 
         builder.appendSeparator("Entity Defaults");
         builder.append("DB Schema:", defaultSchema.getComponent(), updateDefaultSchema);
@@ -210,6 +213,13 @@
                 setDataNode();
             }
         });
+        
+        quoteSQLIdentifiers.addActionListener(new ActionListener(){
+
+            public void actionPerformed(ActionEvent e) {
+                setQuoteSQLIdentifiers(quoteSQLIdentifiers.isSelected());
+            }
+        });
 
         defaultLockType.addActionListener(new ActionListener() {
 
@@ -279,6 +289,7 @@
         String locationText = map.getLocation();
         location.setText((locationText != null) ? locationText : "(no file)");
 
+        quoteSQLIdentifiers.setSelected(map.isQuotingSQLIdentifiers());
         // rebuild data node list
         Object nodes[] = eventController.getCurrentDataDomain().getDataNodes().toArray();
 
@@ -357,6 +368,20 @@
             eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
         }
     }
+    
+    void setQuoteSQLIdentifiers(boolean flag) {
+        DataMap dataMap = eventController.getCurrentDataMap();
+
+        if (dataMap == null) {
+            return;
+        }
+
+        if (dataMap.isQuotingSQLIdentifiers() != flag) {
+            dataMap.setQuotingSQLIdentifiers(flag);
+            
+            eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
+        }
+    }
 
     void setDefaultPackage(String newDefaultPackage) {
         DataMap dataMap = eventController.getCurrentDataMap();



Mime
View raw message