cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r642273 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/art/ java/org/apache/art/auto/ java/org/apache/cayenne/access/ resources/
Date Fri, 28 Mar 2008 16:15:04 GMT
Author: aadamchik
Date: Fri Mar 28 09:14:53 2008
New Revision: 642273

URL: http://svn.apache.org/viewvc?rev=642273&view=rev
Log:
CAY-1018 Enums fetched via SQLTemplate
(commented out test case)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/Enum1.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/EnumEntity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/auto/_EnumEntity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/cayenne.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/Enum1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/Enum1.java?rev=642273&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/Enum1.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/Enum1.java
Fri Mar 28 09:14:53 2008
@@ -0,0 +1,23 @@
+/*****************************************************************
+ *   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.art;
+
+public enum Enum1 {
+    one, two, three
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/EnumEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/EnumEntity.java?rev=642273&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/EnumEntity.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/EnumEntity.java
Fri Mar 28 09:14:53 2008
@@ -0,0 +1,7 @@
+package org.apache.art;
+
+import org.apache.art.auto._EnumEntity;
+
+public class EnumEntity extends _EnumEntity {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/auto/_EnumEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/auto/_EnumEntity.java?rev=642273&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/auto/_EnumEntity.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/art/auto/_EnumEntity.java
Fri Mar 28 09:14:53 2008
@@ -0,0 +1,25 @@
+package org.apache.art.auto;
+
+import org.apache.art.Enum1;
+import org.apache.cayenne.CayenneDataObject;
+
+/**
+ * Class _EnumEntity 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 _EnumEntity extends CayenneDataObject {
+
+    public static final String ENUM_ATTRIBUTE_PROPERTY = "enumAttribute";
+
+    public static final String ID_PK_COLUMN = "ID";
+
+    public void setEnumAttribute(Enum1 enumAttribute) {
+        writeProperty("enumAttribute", enumAttribute);
+    }
+    public Enum1 getEnumAttribute() {
+        return (Enum1)readProperty("enumAttribute");
+    }
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java?rev=642273&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
Fri Mar 28 09:14:53 2008
@@ -0,0 +1,82 @@
+/*****************************************************************
+ *   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 org.apache.art.Enum1;
+import org.apache.art.EnumEntity;
+import org.apache.cayenne.DataObjectUtils;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.unit.CayenneCase;
+
+public class EnumTest extends CayenneCase {
+
+    public void testInsert() {
+        ObjectContext context = createDataContext();
+
+        EnumEntity e = context.newObject(EnumEntity.class);
+        e.setEnumAttribute(Enum1.one);
+
+        context.commitChanges();
+    }
+
+    public void testSelectQuery() throws Exception {
+        deleteTestData();
+        ObjectContext context = createDataContext();
+
+        context.performGenericQuery(new SQLTemplate(
+                EnumEntity.class,
+                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (1, 'two')"));
+        context.performGenericQuery(new SQLTemplate(
+                EnumEntity.class,
+                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (2, 'one')"));
+
+        SelectQuery q = new SelectQuery(EnumEntity.class);
+        q.andQualifier(ExpressionFactory.matchExp(
+                EnumEntity.ENUM_ATTRIBUTE_PROPERTY,
+                Enum1.one));
+
+        EnumEntity e = (EnumEntity) DataObjectUtils.objectForQuery(context, q);
+        assertNotNull(e);
+        assertSame(Enum1.one, e.getEnumAttribute());
+    }
+
+    public void testSQLTemplate() throws Exception {
+        deleteTestData();
+        ObjectContext context = createDataContext();
+
+        context.performGenericQuery(new SQLTemplate(
+                EnumEntity.class,
+                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (1, 'two')"));
+        context.performGenericQuery(new SQLTemplate(
+                EnumEntity.class,
+                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (2, 'one')"));
+
+        SQLTemplate q = new SQLTemplate(
+                EnumEntity.class,
+                "SELECT * FROM ENUM_ENTITY WHERE ENUM_ATTRIBUTE = 'one'");
+        q.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+
+        EnumEntity e = (EnumEntity) DataObjectUtils.objectForQuery(context, q);
+        assertNotNull(e);
+       // assertSame(Enum1.one, e.getEnumAttribute());
+    }
+}

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=642273&r1=642272&r2=642273&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
Fri Mar 28 09:14:53 2008
@@ -11,6 +11,4 @@
 	<map name="relationships" location="relationships.map.xml"/>
 	<map name="testmap" location="testmap.map.xml"/>
 </domain>
-<view name="dataview0" location="dataview0.view.xml"/>
-<view name="dataview1" location="dataview1.view.xml"/>
 </domains>

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=642273&r1=642272&r2=642273&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
Fri Mar 28 09:14:53 2008
@@ -115,6 +115,10 @@
 		<db-attribute name="DECIMAL_PK" type="DECIMAL" isPrimaryKey="true" isMandatory="true"/>
 		<db-attribute name="NAME" type="VARCHAR" length="100"/>
 	</db-entity>
+	<db-entity name="ENUM_ENTITY">
+		<db-attribute name="ENUM_ATTRIBUTE" type="VARCHAR" length="250"/>
+		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
+	</db-entity>
 	<db-entity name="EXHIBIT">
 		<db-attribute name="CLOSING_DATE" type="TIMESTAMP" isMandatory="true"/>
 		<db-attribute name="EXHIBIT_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
@@ -320,6 +324,9 @@
 	<obj-entity name="DecimalPKTestEntity" className="org.apache.art.DecimalPKTestEntity"
dbEntityName="DECIMAL_PK_TST">
 		<obj-attribute name="decimalPK" type="java.math.BigDecimal" db-attribute-path="DECIMAL_PK"/>
 		<obj-attribute name="name" type="java.lang.String" db-attribute-path="NAME"/>
+	</obj-entity>
+	<obj-entity name="EnumEntity" className="org.apache.art.EnumEntity" dbEntityName="ENUM_ENTITY">
+		<obj-attribute name="enumAttribute" type="org.apache.art.Enum1" db-attribute-path="ENUM_ATTRIBUTE"/>
 	</obj-entity>
 	<obj-entity name="Exhibit" className="org.apache.art.Exhibit" dbEntityName="EXHIBIT">
 		<obj-attribute name="closingDate" type="java.util.Date" db-attribute-path="CLOSING_DATE"/>



Mime
View raw message