openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mprud...@apache.org
Subject svn commit: r586649 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/util/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/ openjpa-persistence-jdbc/src/tes...
Date Sat, 20 Oct 2007 00:49:38 GMT
Author: mprudhom
Date: Fri Oct 19 17:49:37 2007
New Revision: 586649

URL: http://svn.apache.org/viewvc?rev=586649&view=rev
Log:
OPENJPA-322 reverted change #567170 to restore previous behavior of TimeZones in Calendar
fields; added test case to confirm that the Calendar fields behave as expected

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestCalendarField.java
  (with props)
Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java?rev=586649&r1=586648&r2=586649&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
Fri Oct 19 17:49:37 2007
@@ -92,10 +92,7 @@
                 proxy = checkProxy();
                 if (proxy == null) {
                     proxy = (Proxy) _sm.newFieldProxy(field);
-                    Calendar pcal = (Calendar) proxy;
-                    Calendar ocal = (Calendar) objval;
-                    pcal.setTime (ocal.getTime ());
-                    pcal.setTimeZone (ocal.getTimeZone ());
+                    ((Calendar) proxy).setTime(((Calendar) objval).getTime());
                     ret = true;
                 }
                 break;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java?rev=586649&r1=586648&r2=586649&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java
Fri Oct 19 17:49:37 2007
@@ -18,8 +18,6 @@
  */
 package org.apache.openjpa.util;
 
-import java.util.TimeZone;
-
 /**
  * Interface implemented by all generated proxies on {@link java.util.Calendar}
  * types.

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestCalendarField.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestCalendarField.java?rev=586649&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestCalendarField.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestCalendarField.java
Fri Oct 19 17:49:37 2007
@@ -0,0 +1,57 @@
+/*
+ * 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.openjpa.jdbc.meta;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.simple.TemporalFieldTypes;
+import org.apache.openjpa.persistence.test.SingleEMTestCase;
+
+public class TestCalendarField extends SingleEMTestCase {
+
+    public void setUp() {
+        setUp(TemporalFieldTypes.class);
+    }
+
+    public void testCalendarField() throws IOException, SQLException {
+        TimeZone tz = TimeZone.getTimeZone("Europe/Budapest");
+
+        for (TemporalFieldTypes t : find(TemporalFieldTypes.class))
+            remove(t);
+
+        TemporalFieldTypes tft;
+
+        tft = new TemporalFieldTypes();
+        assertEquals(tz, tft.getCalendarTimeZoneField().getTimeZone());
+
+        persist(tft);
+
+        // get a fresh EM
+        reset();
+
+        tft = find(TemporalFieldTypes.class).get(0);
+        assertEquals(tz, tft.getCalendarTimeZoneField().getTimeZone());
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestCalendarField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java?rev=586649&r1=586648&r2=586649&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java
Fri Oct 19 17:49:37 2007
@@ -20,6 +20,7 @@
 
 import java.util.Calendar;
 import java.util.Date;
+import java.util.TimeZone;
 import javax.persistence.Entity;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
@@ -51,6 +52,9 @@
     @Temporal(TemporalType.TIMESTAMP)
     private Calendar calendarTimestampField;
 
+    private Calendar calendarTimeZoneField =
+        Calendar.getInstance(TimeZone.getTimeZone("Europe/Budapest"));
+
     public void setDateDefaultField(Date date) {
         this.dateDefaultField = date;
     }
@@ -114,4 +118,13 @@
     public Calendar getCalendarTimeStampField() {
         return this.calendarTimestampField;
     }
+
+    public void setCalendarTimeZoneField(Calendar calendarTimeZoneField) {
+        this.calendarTimeZoneField = calendarTimeZoneField;
+    }
+
+    public Calendar getCalendarTimeZoneField() {
+        return this.calendarTimeZoneField;
+    }
+
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java?rev=586649&r1=586648&r2=586649&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java
Fri Oct 19 17:49:37 2007
@@ -47,6 +47,14 @@
         em = emf.createEntityManager(); 
     }
 
+    /** 
+     * Clear the current EntityManager and re-initialize it.
+     */
+    protected void reset() {
+        close();
+        em = emf.createEntityManager(); 
+    }
+
     @Override
     public void tearDown() throws Exception {
         rollback();



Mime
View raw message