cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r741891 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/dba/ main/java/org/apache/cayenne/dba/db2/ main/java/org/apache/cayenne/dba/openbase/ main/java/org/apache/cayenne/dba/oracle/ main/java...
Date Sat, 07 Feb 2009 13:32:03 GMT
Author: aadamchik
Date: Sat Feb  7 13:32:02 2009
New Revision: 741891

URL: http://svn.apache.org/viewvc?rev=741891&view=rev
Log:
ITS-289 Implement Quoting of identifiers

patch by Olga. PostgreSQL quoting, more unit tests

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContexQuoteTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/QuoteAdress.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quote_Person.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quotemap.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quotemap.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quotemap.map.xml
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/oracle/OraclePkGeneratorTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AbstractAccessStack.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneCase.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/spring-test-resources.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
Sat Feb  7 13:32:02 2009
@@ -631,8 +631,8 @@
     public QuotingStrategy  getQuotingStrategy(boolean needQuotes) {
         if (needQuotes) {
             return new QuoteStrategy(
-                    getIdentifiersStartQuote(),
-                    getIdentifiersEndQuote());
+                    this.getIdentifiersStartQuote(),
+                    this.getIdentifiersEndQuote());
         }
         else {
             return new NoQuoteStrategy();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
Sat Feb  7 13:32:02 2009
@@ -38,7 +38,6 @@
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.QueryLogger;
 import org.apache.cayenne.access.ResultIterator;
-import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbKeyGenerator;
@@ -504,12 +503,4 @@
                     + entityName, ex);
         }
     }
-    
-    protected QuotingStrategy getContextQuoteStrategy(DataMap dm) {
-        if(dm!=null && dm.isQuotingSQLIdentifiers()){
-            return new QuoteStrategy(getAdapter().getIdentifiersStartQuote(), getAdapter().getIdentifiersEndQuote());
-        } else {
-            return new NoQuoteStrategy();           
-       }    
-   } 
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
Sat Feb  7 13:32:02 2009
@@ -225,7 +225,13 @@
      * Returns default sequence name for DbEntity.
      */
     protected String sequenceName(DbEntity entity) {
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        boolean status;
+        if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){

+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getAdapter().getQuotingStrategy(status);
         String entName = entity.getName();
         String seqName = _SEQUENCE_PREFIX + entName;
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java
Sat Feb  7 13:32:02 2009
@@ -293,7 +293,14 @@
 
         StringBuilder buffer = new StringBuilder();        
         buffer.append("CREATE PRIMARY KEY ");
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        boolean status;
+        if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){

+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getAdapter().getQuotingStrategy(status);
+
         buffer.append(context.quoteString(entity.getName()));
 
         buffer.append(" (");
@@ -320,7 +327,13 @@
      */
     protected String createUniquePKIndexString(DbEntity entity) {
         Collection<DbAttribute> pk = entity.getPrimaryKeys();
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        boolean status;
+        if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){

+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getAdapter().getQuotingStrategy(status);
         if (pk == null || pk.size() == 0) {
             throw new CayenneRuntimeException("Entity '"
                     + entity.getName()

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java
Sat Feb  7 13:32:02 2009
@@ -261,7 +261,14 @@
 
     /** Returns expected primary key sequence name for a DbEntity. */
     protected String sequenceName(DbEntity entity) {
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        boolean status;
+        if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){

+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getAdapter().getQuotingStrategy(status);
+
         // use custom generator if possible
         DbKeyGenerator keyGenerator = entity.getPrimaryKeyGenerator();
         if (keyGenerator != null
@@ -278,6 +285,8 @@
 
                 seqName = context.quoteString(entity.getSchema()) + "." + 
                 context.quoteString(seqName);
+             } else {
+                seqName = context.quoteString(seqName);
              }
             return seqName;
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
Sat Feb  7 13:32:02 2009
@@ -121,8 +121,13 @@
      */
     @Override
     public String createTable(DbEntity ent) {
-       
-        QuotingStrategy context = getQuotingStrategy(ent.getDataMap().isQuotingSQLIdentifiers());
+        boolean status;
+        if(ent.getDataMap()!=null && ent.getDataMap().isQuotingSQLIdentifiers()){

+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getQuotingStrategy(status);
         StringBuilder buf = new StringBuilder();
         buf.append("CREATE TABLE ");
         

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
Sat Feb  7 13:32:02 2009
@@ -31,6 +31,7 @@
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.QueryLogger;
 import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.dba.oracle.OraclePkGenerator;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbKeyGenerator;
@@ -166,6 +167,14 @@
     @Override
     protected List<String> getExistingSequences(DataNode node) throws SQLException
{
 
+        boolean status;
+        if(node.getDataMap(node.getName())!=null && node.getDataMap(node.getName()).isQuotingSQLIdentifiers()){

+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getAdapter().getQuotingStrategy(status);
+
         // check existing sequences
         Connection con = node.getDataSource().getConnection();
 
@@ -177,8 +186,8 @@
                 ResultSet rs = sel.executeQuery(sql);
                 try {
                     List<String> sequenceList = new ArrayList<String>();
-                    while (rs.next()) {
-                        sequenceList.add(rs.getString(1));
+                    while (rs.next()) {                        
+                        sequenceList.add(context.quoteString(rs.getString(1)));
                     }
                     return sequenceList;
                 }

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContexQuoteTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContexQuoteTest.java?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContexQuoteTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContexQuoteTest.java
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,108 @@
+/*****************************************************************
+ *   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;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.UpdateBatchQuery;
+import org.apache.cayenne.testdo.quotemap.QuoteAdress;
+import org.apache.cayenne.testdo.quotemap.Quote_Person;
+import org.apache.cayenne.unit.AccessStack;
+import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.CayenneResources;
+
+
+
+public class DataContexQuoteTest extends CayenneCase{
+    private DataContext context;
+
+    @Override
+    protected AccessStack buildAccessStack() {
+        return CayenneResources.getResources().getAccessStack(QUOTEMAP_ACCESS_STACK);
+    }
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        deleteTestData();
+        context = createDataContext();
+    }
+    
+    public void testPrefetchQuote() throws Exception {
+        
+        // work with tables QuoteAdress and Quote_Person. 
+        // In this table parameter quoteSqlIdentifiers = true. 
+        
+        QuoteAdress quoteAdress = (QuoteAdress) context.newObject("QuoteAdress");
+        quoteAdress.setCity("city");
+        
+        Quote_Person quote_Person = (Quote_Person) context.newObject("Quote_Person");
+        quote_Person.setSalary(10000);
+        quote_Person.setName("Arcadi");
+        
+        context.commitChanges();
+        
+        SelectQuery q = new SelectQuery(QuoteAdress.class);
+        List objects = context.performQuery(q);
+        assertEquals(1, objects.size());
+        
+        
+        SelectQuery qQuote_Person = new SelectQuery(Quote_Person.class);
+        List objects2 = context.performQuery(qQuote_Person);
+        assertEquals(1, objects2.size());
+        
+        QuoteAdress quoteAdress2 = (QuoteAdress) context.newObject("QuoteAdress");
+        quoteAdress2.setCity("city2");
+        
+        Quote_Person quote_Person2 = (Quote_Person) context.newObject("Quote_Person");
+        quote_Person2.setSalary(100);
+        quote_Person2.setName("Name");
+        quote_Person2.setDAte(new Date());
+        
+        context.commitChanges();
+        
+        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
+                QuoteAdress.class).getDbEntity();
+        List idAttributes = Collections.singletonList(entity
+                    .getAttribute("City"));
+        List updatedAttributes = Collections.singletonList(entity
+                    .getAttribute("City"));
+
+        UpdateBatchQuery updateQuery = new UpdateBatchQuery(
+                    entity,
+                    idAttributes,
+                    updatedAttributes,
+                    null,
+                    1);
+        
+        List objects3 = context.performQuery(updateQuery);
+        assertEquals(0, objects3.size());
+  
+        SelectQuery qQuote_Person2 = new SelectQuery(Quote_Person.class);
+        List objects4 = context.performQuery(qQuote_Person);
+        assertEquals(2, objects4.size());
+ 
+        
+    }
+
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
Sat Feb  7 13:32:02 2009
@@ -95,11 +95,10 @@
                     idAttributes,
                     null,
                     1);
-            DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(
-                    new JdbcAdapter());
-            String generatedSql = builder.createSqlString(deleteQuery);
-
             JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);
+            String generatedSql = builder.createSqlString(deleteQuery);
+            
             String charStart = adapter.getIdentifiersStartQuote();
             String charEnd = adapter.getIdentifiersEndQuote();
 
@@ -138,11 +137,12 @@
                     idAttributes,
                     nullAttributes,
                     1);
-            DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(
-                    new JdbcAdapter());
+            
+            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            
+            DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);
             String generatedSql = builder.createSqlString(deleteQuery);
 
-            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
             String charStart = adapter.getIdentifiersStartQuote();
             String charEnd = adapter.getIdentifiersEndQuote();
             assertNotNull(generatedSql);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilderTest.java
Sat Feb  7 13:32:02 2009
@@ -62,12 +62,12 @@
             entity.getDataMap().setQuotingSQLIdentifiers(true);
             List idAttributes = Collections.singletonList(entity
                     .getAttribute("LOCKING_TEST_ID"));
-
+           
+            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            
             InsertBatchQuery deleteQuery = new InsertBatchQuery(entity, 1);
-            InsertBatchQueryBuilder builder = new InsertBatchQueryBuilder(
-                    new JdbcAdapter());
+            InsertBatchQueryBuilder builder = new InsertBatchQueryBuilder(adapter);
             String generatedSql = builder.createSqlString(deleteQuery);
-            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
             String charStart = adapter.getIdentifiersStartQuote();
             String charEnd = adapter.getIdentifiersEndQuote();
             assertNotNull(generatedSql);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java
Sat Feb  7 13:32:02 2009
@@ -110,11 +110,11 @@
                     updatedAttributes,
                     null,
                     1);
-            UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(
-                    new JdbcAdapter());
-            String generatedSql = builder.createSqlString(updateQuery);
-            
             JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            
+            UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
+            String generatedSql = builder.createSqlString(updateQuery);
+  
             String charStart = adapter.getIdentifiersStartQuote();
             String charEnd = adapter.getIdentifiersEndQuote();
             
@@ -160,11 +160,12 @@
                     updatedAttributes,
                     nullAttributes,
                     1);
-            UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(
-                    new JdbcAdapter());
+            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            
+            UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
             String generatedSql = builder.createSqlString(updateQuery);
             assertNotNull(generatedSql);
-            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+  
             String charStart = adapter.getIdentifiersStartQuote();
             String charEnd = adapter.getIdentifiersEndQuote();
             assertEquals("UPDATE "

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/oracle/OraclePkGeneratorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/oracle/OraclePkGeneratorTest.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/oracle/OraclePkGeneratorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/oracle/OraclePkGeneratorTest.java
Sat Feb  7 13:32:02 2009
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.dba.oracle;
 
+import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbKeyGenerator;
 import org.apache.cayenne.unit.CayenneCase;
@@ -30,7 +31,7 @@
 
     @Override
     protected void setUp() throws Exception {
-        pkGenerator = new OraclePkGenerator();
+        pkGenerator = new OraclePkGenerator((JdbcAdapter)getAccessStackAdapter().getAdapter());
     }
 
     public void testSequenceNameDefault() throws Exception {

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/QuoteAdress.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/QuoteAdress.java?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/QuoteAdress.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/QuoteAdress.java
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.quotemap;
+
+import org.apache.cayenne.testdo.quotemap.auto._QuoteAdress;
+
+public class QuoteAdress extends _QuoteAdress {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quote_Person.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quote_Person.java?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quote_Person.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quote_Person.java
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.quotemap;
+
+import org.apache.cayenne.testdo.quotemap.auto._Quote_Person;
+
+public class Quote_Person extends _Quote_Person {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quotemap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quotemap.java?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quotemap.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/Quotemap.java
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,18 @@
+package org.apache.cayenne.testdo.quotemap;
+
+import org.apache.cayenne.testdo.quotemap.auto._Quotemap;
+
+public class Quotemap extends _Quotemap {
+
+    private static Quotemap instance;
+
+    private Quotemap() {}
+
+    public static Quotemap getInstance() {
+        if(instance == null) {
+            instance = new Quotemap();
+        }
+
+        return instance;
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_QuoteAdress.java
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,24 @@
+package org.apache.cayenne.testdo.quotemap.auto;
+
+import org.apache.cayenne.CayenneDataObject;
+
+/**
+ * Class _QuoteAdress was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _QuoteAdress extends CayenneDataObject {
+
+    public static final String CITY_PROPERTY = "city";
+
+    public static final String ADRES_ID_PK_COLUMN = "ADRES ID";
+
+    public void setCity(String city) {
+        writeProperty("city", city);
+    }
+    public String getCity() {
+        return (String)readProperty("city");
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quote_Person.java
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,50 @@
+package org.apache.cayenne.testdo.quotemap.auto;
+
+import java.util.Date;
+
+import org.apache.cayenne.CayenneDataObject;
+
+/**
+ * Class _Quote_Person was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _Quote_Person extends CayenneDataObject {
+
+    public static final String D_ATE_PROPERTY = "dAte";
+    public static final String F_ULL_NAME_PROPERTY = "fULL_name";
+    public static final String NAME_PROPERTY = "name";
+    public static final String SALARY_PROPERTY = "salary";
+
+    public static final String ID_PK_COLUMN = "id";
+
+    public void setDAte(Date dAte) {
+        writeProperty("dAte", dAte);
+    }
+    public Date getDAte() {
+        return (Date)readProperty("dAte");
+    }
+
+    public void setFULL_name(String fULL_name) {
+        writeProperty("fULL_name", fULL_name);
+    }
+    public String getFULL_name() {
+        return (String)readProperty("fULL_name");
+    }
+
+    public void setName(String name) {
+        writeProperty("name", name);
+    }
+    public String getName() {
+        return (String)readProperty("name");
+    }
+
+    public void setSalary(Integer salary) {
+        writeProperty("salary", salary);
+    }
+    public Integer getSalary() {
+        return (Integer)readProperty("salary");
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quotemap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quotemap.java?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quotemap.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/quotemap/auto/_Quotemap.java
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,12 @@
+package org.apache.cayenne.testdo.quotemap.auto;
+
+
+
+/**
+ * This class was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public class _Quotemap {
+}
\ No newline at end of file

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=741891&r1=741890&r2=741891&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
Sat Feb  7 13:32:02 2009
@@ -38,6 +38,7 @@
 import org.apache.cayenne.access.DbGenerator;
 import org.apache.cayenne.access.QueryLogger;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -147,8 +148,17 @@
             ListIterator it = list.listIterator(list.size());
             while (it.hasPrevious()) {
                 DbEntity ent = (DbEntity) it.previous();
+                
+                boolean status;
+                if(ent.getDataMap()!=null && ent.getDataMap().isQuotingSQLIdentifiers()){

+                    status= true;
+                } else {
+                    status = false;
+                }
+
+                QuotingStrategy strategy =  getAdapter(node).getQuotingStrategy(status);
 
-                String deleteSql = "DELETE FROM " + ent.getName();
+                String deleteSql = "DELETE FROM " + strategy.quoteString(ent.getName());
 
                 try {
                     stmt.executeUpdate(deleteSql);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
Sat Feb  7 13:32:02 2009
@@ -35,6 +35,7 @@
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.Procedure;
@@ -327,4 +328,8 @@
 
         return constraintMap;
     }
+
+    public QuotingStrategy getQuotingStrategy(boolean status) {
+        return adapter.getQuotingStrategy(status);
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneCase.java?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneCase.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneCase.java
Sat Feb  7 13:32:02 2009
@@ -44,6 +44,7 @@
     public static final String TEST_ACCESS_STACK = "TestStack";
     public static final String MULTI_TIER_ACCESS_STACK = "MultiTierStack";
     public static final String QUALIFIED_ACCESS_STACK = "QualifiedStack";
+    public static final String QUOTEMAP_ACCESS_STACK = "QuoteMapStack";
 
     static {
         // create dummy shared config

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne.xml?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne.xml
Sat Feb  7 13:32:02 2009
@@ -10,6 +10,7 @@
 	<map name="multi-tier" location="multi-tier.map.xml"/>
 	<map name="people" location="people.map.xml"/>
 	<map name="qualified" location="qualified.map.xml"/>
+	<map name="quotemap" location="quotemap.map.xml"/>
 	<map name="relationships" location="relationships.map.xml"/>
 	<map name="testmap" location="testmap.map.xml"/>
 </domain>

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quotemap.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quotemap.map.xml?rev=741891&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quotemap.map.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/quotemap.map.xml
Sat Feb  7 13:32:02 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<data-map project-version="3.0">
+	<property name="defaultPackage" value="org.apache.cayenne.testdo.quotemap"/>
+	<property name="quoteSqlIdentifiers" value="true"/>
+	<db-entity name="QUOTE_ADRESS">
+		<db-attribute name="ADRES ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="City" type="VARCHAR" length="200"/>
+	</db-entity>
+	<db-entity name="quote Person">
+		<db-attribute name="DAte" type="DATE"/>
+		<db-attribute name="FULL name" type="VARCHAR" length="300"/>
+		<db-attribute name="NAME" type="VARCHAR" length="100"/>
+		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+		<db-attribute name="salary" type="INTEGER"/>
+	</db-entity>
+	<obj-entity name="QuoteAdress" className="org.apache.cayenne.testdo.quotemap.QuoteAdress"
dbEntityName="QUOTE_ADRESS">
+		<obj-attribute name="city" type="java.lang.String" db-attribute-path="City"/>
+	</obj-entity>
+	<obj-entity name="Quote_Person" className="org.apache.cayenne.testdo.quotemap.Quote_Person"
dbEntityName="quote Person">
+		<obj-attribute name="dAte" type="java.util.Date" db-attribute-path="DAte"/>
+		<obj-attribute name="fULL_name" type="java.lang.String" db-attribute-path="FULL name"/>
+		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+		<obj-attribute name="salary" type="java.lang.Integer" db-attribute-path="salary"/>
+	</obj-entity>
+</data-map>

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/spring-test-resources.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/spring-test-resources.xml?rev=741891&r1=741890&r2=741891&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/spring-test-resources.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/spring-test-resources.xml
Sat Feb  7 13:32:02 2009
@@ -66,6 +66,7 @@
 		<constructor-arg><ref bean="SQLiteAdapter"/></constructor-arg>
 	</bean>
 	
+	
 	<!-- ======================================= -->
 	<!-- DataMaps -->
 	<!-- ======================================= -->
@@ -105,6 +106,10 @@
     <bean id="InheritanceMap" class="org.apache.cayenne.unit.DataMapFactory">
         <constructor-arg><value>inheritance.map.xml</value></constructor-arg>
     </bean>
+    <bean id="QuoteMap" class="org.apache.cayenne.unit.DataMapFactory">
+        <constructor-arg><value>quotemap.map.xml</value></constructor-arg>
+    </bean>
+    
 	
 	<!-- ======================================= -->
 	<!-- DataSetFactory -->
@@ -173,6 +178,11 @@
         <constructor-arg><ref bean="DataSetFactory"/></constructor-arg>
         <constructor-arg><list><ref bean="InheritanceMap"/></list></constructor-arg>
     </bean>
+    <bean id="QuoteMapStack" class="org.apache.cayenne.unit.SimpleAccessStack">
+        <constructor-arg><ref bean="TestResources"/></constructor-arg>
+        <constructor-arg><ref bean="DataSetFactory"/></constructor-arg>
+        <constructor-arg><list><ref bean="QuoteMap"/></list></constructor-arg>
+    </bean>
 	<!-- Used to create DB schema to avoid conflicts when schema for individual stacks is
generated. -->
 	<bean id="SchemaSetupStack" class="org.apache.cayenne.unit.SimpleAccessStack">
 		<constructor-arg><ref bean="TestResources"/></constructor-arg>
@@ -190,6 +200,7 @@
 				<ref bean="EmbeddingMap"/>
 				<ref bean="QualifiedMap"/>
                 <ref bean="InheritanceMap"/>
+                <ref bean="QuoteMap"/>
 			</list>
 		</constructor-arg>
 	</bean>



Mime
View raw message