openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r779833 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1: Division.java TestSpec10_1_29_Ex1.java
Date Fri, 29 May 2009 04:26:29 GMT
Author: fancy
Date: Fri May 29 04:26:29 2009
New Revision: 779833

URL: http://svn.apache.org/viewvc?rev=779833&view=rev
Log:
OPENJPA-967 add query test string  for JPA2 path nagivation thru KEY appear in FROM clause

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/Division.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/Division.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/Division.java?rev=779833&r1=779832&r2=779833&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/Division.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/Division.java
Fri May 29 04:26:29 2009
@@ -18,6 +18,12 @@
  */
 package org.apache.openjpa.persistence.jdbc.maps.spec_10_1_29_ex1;
 
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
@@ -29,6 +35,10 @@
     int id;
 
     String name;
+    @ElementCollection
+    @CollectionTable(name="branch")
+    @Column(name="branch", length=20)
+    protected Set<String> branches = new HashSet<String>();
 
     public int getId() {
         return id;
@@ -46,6 +56,14 @@
         this.name = name;
     }
 
+    public Set<String> getBranches() {
+        return branches;
+    }
+
+    public void addBranch(String name) {
+        branches.add(name);
+    }
+
     public boolean equals(Object o) {
         Division d = (Division) o;
         if (d.name.equals(name) &&

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java?rev=779833&r1=779832&r2=779833&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java
Fri May 29 04:26:29 2009
@@ -86,6 +86,15 @@
         Division d = (Division) ((Object[]) rs.get(0))[0];
         VicePresident v = (VicePresident) ((Object[]) rs.get(0))[1];
 
+        query = "select KEY(e), b from Company c, " +
+            " in (c.organization) e, in(KEY(e).branches) b order by b";
+        q = em.createQuery(query);
+        if (inMemory) 
+            setCandidate(q, Company.class);
+        rs = q.getResultList();
+        String branch = (String) ((Object[]) rs.get(0))[1];
+        assertEquals(branch, "branch0");
+
         em.clear();
         query = "select ENTRY(e) from Company c, " +
             " in (c.organization) e order by c.id";
@@ -160,6 +169,9 @@
         Division d = new Division();
         d.setId(id);
         d.setName("d" + id);
+        for (int i = 0; i < 2; i++) {
+            d.addBranch("branch"+i);
+        }
         return d;
     }
 



Mime
View raw message