mirror of https://github.com/apache/openjpa.git
OPENJPA-967 JPA2 Query support for embeddable MapKey improvement/rework
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@764279 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8c31381f18
commit
4da7ad3790
|
@ -809,31 +809,18 @@ public class PCPath
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void calculateValue(Select sel, ExpContext ctx, ExpState state,
|
||||
|
|
|
@ -47,7 +47,11 @@ public class EmbeddedClassStrategy
|
|||
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());
|
||||
|
|
|
@ -81,12 +81,22 @@ public class RelationMapInverseKeyFieldStrategy
|
|||
|
||||
public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
|
||||
JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) {
|
||||
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 {
|
||||
ValueMapping vm = field.getKeyMapping();
|
||||
if (vm.isEmbedded())
|
||||
return vm.getValueMappedByMapping().
|
||||
loadProjection(store, fetch, res, joins);
|
||||
else
|
||||
throw new InternalException();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.sql.SQLException;
|
|||
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,12 +80,22 @@ public class RelationMapTableFieldStrategy
|
|||
|
||||
public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
|
||||
JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) {
|
||||
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 {
|
||||
ValueMapping vm = field.getKeyMapping();
|
||||
if (vm.isEmbedded())
|
||||
return vm.getValueMappedByMapping().
|
||||
loadProjection(store, fetch, res, joins);
|
||||
else
|
||||
throw new InternalException();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue