cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r705253 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/query/SQLTemplate.java test/java/org/apache/cayenne/access/DataContextNamedQueryCachingTest.java test/resources/testmap.map.xml
Date Thu, 16 Oct 2008 14:25:19 GMT
Author: aadamchik
Date: Thu Oct 16 07:25:18 2008
New Revision: 705253

URL: http://svn.apache.org/viewvc?rev=705253&view=rev
Log:
CAY-1122 Add setColumnNamesCapitalization(String columnNameCapitalization) method to NamedQuery
class

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextNamedQueryCachingTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java?rev=705253&r1=705252&r2=705253&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
Thu Oct 16 07:25:18 2008
@@ -314,6 +314,7 @@
 
         query.metaData.copyFromInfo(this.metaData);
         query.setParameters(parameters);
+        query.setColumnNamesCapitalization(this.getColumnNamesCapitalization());
 
         // The following algorithm is for building the new query name based
         // on the original query name and a hashcode of the map of parameters.

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextNamedQueryCachingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextNamedQueryCachingTest.java?rev=705253&r1=705252&r2=705253&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextNamedQueryCachingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextNamedQueryCachingTest.java
Thu Oct 16 07:25:18 2008
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import org.apache.art.Artist;
+import org.apache.cayenne.DataRow;
 import org.apache.cayenne.query.MockQueryMetadata;
 import org.apache.cayenne.query.NamedQuery;
 import org.apache.cayenne.query.QueryMetadata;
@@ -125,6 +126,27 @@
                 false);
         assertSame(fetchedCached1, fetchedCached2);
     }
+    
+    public void testColumnNameCapitalization() throws Exception{
+        deleteTestData();
+        createTestData("prepare");
+        DataContext context = createDataContext();
+        
+        NamedQuery q1 = new NamedQuery("SelectTestLower");
+        List<DataRow> result1 = context.performQuery(q1);
+
+        NamedQuery q2 = new NamedQuery("SelectTestUpper");
+        List<DataRow> result2 = context.performQuery(q2);
+        
+        assertTrue(result1.get(0).containsKey("date_of_birth"));
+        assertFalse(result1.get(0).containsKey("DATE_OF_BIRTH"));
+        
+        assertFalse(result2.get(0).containsKey("date_of_birth"));
+        assertTrue(result2.get(0).containsKey("DATE_OF_BIRTH"));
+        
+    }
+
+    
 
     public void testSharedCache() throws Exception {
         deleteTestData();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml?rev=705253&r1=705252&r2=705253&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml
Thu Oct 16 07:25:18 2008
@@ -615,6 +615,16 @@
 	<query name="QueryWithSharedCache" factory="org.apache.cayenne.map.SelectQueryBuilder"
root="obj-entity" root-name="Artist">
 		<property name="cayenne.GenericSelectQuery.cacheStrategy" value="SHARED_CACHE"/>
 	</query>
+	<query name="SelectTestLower" factory="org.apache.cayenne.map.SQLTemplateBuilder" root="data-map"
root-name="testmap">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="lower"/>
+		<sql><![CDATA[select * from ARTIST]]></sql>
+	</query>
+	<query name="SelectTestUpper" factory="org.apache.cayenne.map.SQLTemplateBuilder" root="data-map"
root-name="testmap">
+		<property name="cayenne.GenericSelectQuery.fetchingDataRows" value="true"/>
+		<property name="cayenne.SQLTemplate.columnNameCapitalization" value="upper"/>
+		<sql><![CDATA[select * from ARTIST]]></sql>
+	</query>
 	<entity-listener class="org.apache.art.EntityListenerDataMap">
 		<pre-persist method-name="prePersistDataMap1"/>
 		<pre-persist method-name="prePersistDataMap2"/>



Mime
View raw message