openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r764279 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: kernel/exps/PCPath.java meta/strats/EmbeddedClassStrategy.java meta/strats/RelationMapInverseKeyFieldStrategy.java meta/strats/RelationMapTableFieldStrategy.java
Date Sun, 12 Apr 2009 03:19:47 GMT
Author: fancy
Date: Sun Apr 12 03:19:46 2009
New Revision: 764279

URL: http://svn.apache.org/viewvc?rev=764279&view=rev
Log:
OPENJPA-967 JPA2 Query support for embeddable MapKey improvement/rework

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbeddedClassStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java?rev=764279&r1=764278&r2=764279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
Sun Apr 12 03:19:46 2009
@@ -809,31 +809,18 @@
         LRSMapFieldStrategy strategy = (LRSMapFieldStrategy)
             pstate.field.getStrategy();
         ClassMapping mapping = pstate.field.getKeyMapping().getTypeMapping();
-        if (strategy instanceof HandlerRelationMapTableFieldStrategy)
-            strategy.selectKey(sel, mapping, null, ctx.store, ctx.fetch,
-                pstate.joins);
-        else {
-            sel.select(_class.getPrimaryKeyColumns(), pstate.joins);
-            FieldMapping[] fms = mapping.getDefinedFieldMappings();
-            for (int i = 0; i < fms.length; i++)
-                sel.select(fms[i].getColumns(), pstate.joins);
-        }
+        strategy.selectKey(sel, mapping, null, ctx.store, ctx.fetch,
+            pstate.joins);
     }
 
     private Object loadEmbeddedMapKey(ExpContext ctx, ExpState state,
         Result res) throws SQLException {
         PathExpState pstate = (PathExpState) state;
         validateMapStrategy(pstate.field.getStrategy());
-        FieldMapping fmd = (FieldMapping) pstate.field.getKey().
-            getValueMappedByMetaData();
         LRSMapFieldStrategy strategy =
             (LRSMapFieldStrategy) pstate.field.getStrategy();
-        if (strategy instanceof HandlerRelationMapTableFieldStrategy)
-            return strategy.loadKey(null, ctx.store, ctx.fetch, res,
-                pstate.joins);
-        else
-            return fmd.getStrategy().
-                loadProjection(ctx.store, ctx.fetch, res, pstate.joins);
+        return strategy.loadKey(null, ctx.store, ctx.fetch, res,
+            pstate.joins);
     }
 
     public void calculateValue(Select sel, ExpContext ctx, ExpState state, 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbeddedClassStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbeddedClassStrategy.java?rev=764279&r1=764278&r2=764279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbeddedClassStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbeddedClassStrategy.java
Sun Apr 12 03:19:46 2009
@@ -47,7 +47,11 @@
         ClassMappingInfo info = cls.getMappingInfo();
         info.assertNoSchemaComponents(cls, true);
 
-        ClassMapping owner = vm.getFieldMapping().getDefiningMapping();
+        ClassMapping owner = null;
+        if (vm.getValueMappedByMapping() != null)
+            owner = vm.getValueMappedByMapping().getDefiningMapping();
+        else
+            owner = vm.getFieldMapping().getDefiningMapping();
         cls.setIdentityType(owner.getIdentityType());
         cls.setObjectIdType(owner.getObjectIdType(),
             owner.isObjectIdTypeShared());

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java?rev=764279&r1=764278&r2=764279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java
Sun Apr 12 03:19:46 2009
@@ -81,13 +81,23 @@
 
     public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
         JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) {
-        throw new InternalException();
+        ValueMapping vm = field.getKeyMapping();
+        if (vm.isEmbedded())
+            sel.select(key, field.getKeyMapping().getSelectSubclasses(),
+                store, fetch, JDBCFetchConfiguration.EAGER_NONE, joins);
+        else
+            throw new InternalException();
     }
 
     public Object loadKey(OpenJPAStateManager sm, JDBCStore store,
         JDBCFetchConfiguration fetch, Result res, Joins joins)
         throws SQLException {
-        throw new InternalException();
+        ValueMapping vm = field.getKeyMapping();
+        if (vm.isEmbedded())
+            return vm.getValueMappedByMapping().
+                loadProjection(store, fetch, res, joins);
+        else
+            throw new InternalException();
     }
 
     public Object deriveKey(JDBCStore store, Object value) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java?rev=764279&r1=764278&r2=764279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java
Sun Apr 12 03:19:46 2009
@@ -22,7 +22,6 @@
 import java.util.Collection;
 import java.util.Map;
 
-import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
@@ -81,13 +80,23 @@
 
     public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
         JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) {
-        throw new InternalException();
+        ValueMapping vm = field.getKeyMapping();
+        if (vm.isEmbedded())
+            sel.select(key, field.getKeyMapping().getSelectSubclasses(),
+                store, fetch, JDBCFetchConfiguration.EAGER_NONE, joins);
+        else
+            throw new InternalException();
     }
 
     public Object loadKey(OpenJPAStateManager sm, JDBCStore store,
         JDBCFetchConfiguration fetch, Result res, Joins joins)
         throws SQLException {
-        throw new InternalException();
+        ValueMapping vm = field.getKeyMapping();
+        if (vm.isEmbedded())
+            return vm.getValueMappedByMapping().
+                loadProjection(store, fetch, res, joins);
+        else
+            throw new InternalException();
     }
 
     public Object deriveKey(JDBCStore store, Object value) {



Mime
View raw message