You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2007/07/31 19:32:02 UTC

svn commit: r561405 - in /openjpa/trunk/openjpa-persistence-jdbc/src: main/java/org/apache/openjpa/persistence/jdbc/ test/java/org/apache/openjpa/jdbc/meta/ test/java/org/apache/openjpa/persistence/simple/

Author: mikedd
Date: Tue Jul 31 10:32:01 2007
New Revision: 561405

URL: http://svn.apache.org/viewvc?view=rev&rev=561405
Log:
OPENJPA-303 committing on behalf of Albert

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolTemporal.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java   (with props)
Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?view=diff&rev=561405&r1=561404&r2=561405
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java Tue Jul 31 10:32:01 2007
@@ -991,8 +991,10 @@
         if (!cols.isEmpty() && cols.size() != 1)
             throw new MetaDataException(_loc.get("num-cols-mismatch", fm,
                 String.valueOf(cols.size()), "1"));
-        if (cols.isEmpty())
+        if (cols.isEmpty()) {
             cols = Arrays.asList(new Column[]{ new Column() });
+            fm.getValueInfo().setColumns(cols);
+        }
 
         Column col = (Column) cols.get(0);
         switch (anno.value()) {

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolTemporal.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolTemporal.java?view=auto&rev=561405
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolTemporal.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolTemporal.java Tue Jul 31 10:32:01 2007
@@ -0,0 +1,61 @@
+/*
+ * 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 javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.simple.TemporalFieldTypes;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+public class TestMappingToolTemporal extends SQLListenerTestCase {
+
+    public void setUp() {
+        setUp(CLEAR_TABLES, TemporalFieldTypes.class);
+    }
+
+    public void testMappingToolTemporal() throws IOException, SQLException {
+
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persist(new TemporalFieldTypes());
+        em.getTransaction().commit();
+        em.close();
+
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*dateDefaultField TIMESTAMP.*)");
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*dateDateField DATE.*)");
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*dateTimeField TIME.*)");
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*dateTimestampField TIMESTAMP.*)");
+
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*calendarDefaultField TIMESTAMP.*)");
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*calendarDateField DATE.*)");
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*calendarTimeField TIME.*)");
+        assertSQL("CREATE TABLE TemporalFieldTypes "
+                + "(.*calendarTimestampField TIMESTAMP.*)");
+    }
+}

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

Added: 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?view=auto&rev=561405
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java Tue Jul 31 10:32:01 2007
@@ -0,0 +1,117 @@
+/*
+ * 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.persistence.simple;
+
+import java.util.Calendar;
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+public class TemporalFieldTypes {
+
+    // Date mapping - Default to TIMESTAMP
+    private Date dateDefaultField;
+
+    @Temporal(TemporalType.DATE)
+    private Date dateDateField;
+
+    @Temporal(TemporalType.TIME)
+    private Date dateTimeField;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date dateTimestampField;
+    
+    // Calendar mapping - Default to TIMESTAMP
+    private Calendar calendarDefaultField;
+
+    @Temporal(TemporalType.DATE)
+    private Calendar calendarDateField;
+
+    @Temporal(TemporalType.TIME)
+    private Calendar calendarTimeField;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    private Calendar calendarTimestampField;
+
+    public void setDateDefaultField(Date date) {
+        this.dateDefaultField = date;
+    }
+
+    public Date getDateDefaultField() {
+        return this.dateDefaultField;
+    }
+
+    public void setDateDateField(Date date) {
+        this.dateDateField = date;
+    }
+
+    public Date getDateDateField() {
+        return this.dateDateField;
+    }
+
+    public void setDateTimeField(Date date) {
+        this.dateTimeField = date;
+    }
+
+    public Date getDateTimeField() {
+        return this.dateTimeField;
+    }
+
+    public void setDateTimeStampField(Date date) {
+        this.dateTimestampField = date;
+    }
+
+    public Date getDateTimeStampField() {
+        return this.dateTimestampField;
+    }
+
+    public void setCalendarDefaultField(Calendar calendar) {
+        this.calendarDefaultField = calendar;
+    }
+
+    public Calendar getCalendarDefaultField() {
+        return this.calendarDefaultField;
+    }
+
+    public void setCalendarDateField(Calendar calendar) {
+        this.calendarDateField = calendar;
+    }
+
+    public Calendar getCalendarDateField() {
+        return this.calendarDateField;
+    }
+
+    public void setCalendarTimeField(Calendar calendar) {
+        this.calendarTimeField = calendar;
+    }
+
+    public Calendar getCalendarTimeField() {
+        return this.calendarTimeField;
+    }
+
+    public void setCalendarTimeStampField(Calendar calendar) {
+        this.calendarTimestampField = calendar;
+    }
+
+    public Calendar getCalendarTimeStampField() {
+        return this.calendarTimestampField;
+    }
+}

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