openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r891035 - in /openjpa/trunk/openjpa-persistence-jdbc/src: main/java/org/apache/openjpa/persistence/jdbc/ test/java/org/apache/openjpa/persistence/embed/
Date Tue, 15 Dec 2009 22:26:12 GMT
Author: faywang
Date: Tue Dec 15 22:26:11 2009
New Revision: 891035

URL: http://svn.apache.org/viewvc?rev=891035&view=rev
Log:
OPENJPA-1431: fix @Temporal annotation when used in conjunction with @Column and @ElementCollection

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/A.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.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?rev=891035&r1=891034&r2=891035&view=diff
==============================================================================
--- 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 Dec 15 22:26:11 2009
@@ -1480,9 +1480,12 @@
                 String.valueOf(cols.size()), "1"));
         if (cols.isEmpty()) {
             cols = Arrays.asList(new Column[]{ new Column() });
-            if (fm.isElementCollection())
-                fm.getElementMapping().getValueInfo().setColumns(cols);
-            else
+            if (fm.isElementCollection()) {
+                if (!fm.getElementMapping().getValueInfo().getColumns().isEmpty())
+                    cols = fm.getElementMapping().getValueInfo().getColumns();
+                else    
+                    fm.getElementMapping().getValueInfo().setColumns(cols);
+            } else
                 fm.getValueInfo().setColumns(cols);
         }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/A.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/A.java?rev=891035&r1=891034&r2=891035&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/A.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/A.java
Tue Dec 15 22:26:11 2009
@@ -18,13 +18,15 @@
  */
 package org.apache.openjpa.persistence.embed;
 
+import java.util.Collection;
+import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;
 
 import javax.persistence.*;
 
 @Entity
-@Table(name = "A_EMB")
+@Table(name = "A_EMBED")
 public class A implements java.io.Serializable {
 
     @Id
@@ -37,6 +39,14 @@
     @ElementCollection
     protected Set<Embed> embeds = new HashSet();
 
+    @CollectionTable(name = "collectionTemporalOrderColumnTable", 
+            joinColumns = @JoinColumn(name = "parent_id"))
+    @ElementCollection(fetch = FetchType.EAGER)
+    @Column(name = "value")
+    @OrderColumn(name = "valueOrderColumn")
+    @Temporal(TemporalType.DATE)
+    private Collection<Date> collectionDate;
+
     public String getId() {
         return id;
     }
@@ -68,5 +78,14 @@
     public void setEmbeds(Set<Embed> embeds) {
         this.embeds = embeds;
     }
+    
+    public Collection<Date> getCollectionDate() {
+        return collectionDate;
+    }
+
+    public void setCollectionDate(Collection<Date> collectionDate) {
+        this.collectionDate = collectionDate;
+    }
+    
 }    
    

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java?rev=891035&r1=891034&r2=891035&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/embed/TestEmbeddable.java
Tue Dec 15 22:26:11 2009
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.sql.SQLException;
 import java.sql.Timestamp;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
@@ -2975,8 +2976,11 @@
         Set embeds = new HashSet();
         embeds.add(embed);
         a.setEmbeds(embeds);
+        Collection<Date> dates = new ArrayList<Date>();
+        dates.add(new Date());
+        a.setCollectionDate(dates);
+        em.persist(a);
         tran.commit();
-        em.close();
         boolean found = false;
         for (String sqlStr : sql) {
             if (sqlStr.toUpperCase().indexOf("A_EMBEDS") != -1) {
@@ -2986,7 +2990,13 @@
         }
         assertTrue(found);
         
+        found = false;
+        for (String sqlStr : sql) {
+            if (sqlStr.toUpperCase().indexOf("VALUE") != -1) {
+                found = true;
+                break;
+            } 
+        }
+        assertTrue(found);
     }
-    
-    
 }



Mime
View raw message