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)
|
LRSMapFieldStrategy strategy = (LRSMapFieldStrategy)
|
||||||
pstate.field.getStrategy();
|
pstate.field.getStrategy();
|
||||||
ClassMapping mapping = pstate.field.getKeyMapping().getTypeMapping();
|
ClassMapping mapping = pstate.field.getKeyMapping().getTypeMapping();
|
||||||
if (strategy instanceof HandlerRelationMapTableFieldStrategy)
|
strategy.selectKey(sel, mapping, null, ctx.store, ctx.fetch,
|
||||||
strategy.selectKey(sel, mapping, null, ctx.store, ctx.fetch,
|
pstate.joins);
|
||||||
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,
|
private Object loadEmbeddedMapKey(ExpContext ctx, ExpState state,
|
||||||
Result res) throws SQLException {
|
Result res) throws SQLException {
|
||||||
PathExpState pstate = (PathExpState) state;
|
PathExpState pstate = (PathExpState) state;
|
||||||
validateMapStrategy(pstate.field.getStrategy());
|
validateMapStrategy(pstate.field.getStrategy());
|
||||||
FieldMapping fmd = (FieldMapping) pstate.field.getKey().
|
|
||||||
getValueMappedByMetaData();
|
|
||||||
LRSMapFieldStrategy strategy =
|
LRSMapFieldStrategy strategy =
|
||||||
(LRSMapFieldStrategy) pstate.field.getStrategy();
|
(LRSMapFieldStrategy) pstate.field.getStrategy();
|
||||||
if (strategy instanceof HandlerRelationMapTableFieldStrategy)
|
return strategy.loadKey(null, ctx.store, ctx.fetch, res,
|
||||||
return strategy.loadKey(null, ctx.store, ctx.fetch, res,
|
pstate.joins);
|
||||||
pstate.joins);
|
|
||||||
else
|
|
||||||
return fmd.getStrategy().
|
|
||||||
loadProjection(ctx.store, ctx.fetch, res, pstate.joins);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculateValue(Select sel, ExpContext ctx, ExpState state,
|
public void calculateValue(Select sel, ExpContext ctx, ExpState state,
|
||||||
|
|
|
@ -47,7 +47,11 @@ public class EmbeddedClassStrategy
|
||||||
ClassMappingInfo info = cls.getMappingInfo();
|
ClassMappingInfo info = cls.getMappingInfo();
|
||||||
info.assertNoSchemaComponents(cls, true);
|
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.setIdentityType(owner.getIdentityType());
|
||||||
cls.setObjectIdType(owner.getObjectIdType(),
|
cls.setObjectIdType(owner.getObjectIdType(),
|
||||||
owner.isObjectIdTypeShared());
|
owner.isObjectIdTypeShared());
|
||||||
|
|
|
@ -81,13 +81,23 @@ public class RelationMapInverseKeyFieldStrategy
|
||||||
|
|
||||||
public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
|
public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
|
||||||
JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) {
|
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,
|
public Object loadKey(OpenJPAStateManager sm, JDBCStore store,
|
||||||
JDBCFetchConfiguration fetch, Result res, Joins joins)
|
JDBCFetchConfiguration fetch, Result res, Joins joins)
|
||||||
throws SQLException {
|
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) {
|
public Object deriveKey(JDBCStore store, Object value) {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.sql.SQLException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
|
||||||
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
||||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||||
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
import org.apache.openjpa.jdbc.meta.ClassMapping;
|
||||||
|
@ -81,13 +80,23 @@ public class RelationMapTableFieldStrategy
|
||||||
|
|
||||||
public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
|
public void selectKey(Select sel, ClassMapping key, OpenJPAStateManager sm,
|
||||||
JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) {
|
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,
|
public Object loadKey(OpenJPAStateManager sm, JDBCStore store,
|
||||||
JDBCFetchConfiguration fetch, Result res, Joins joins)
|
JDBCFetchConfiguration fetch, Result res, Joins joins)
|
||||||
throws SQLException {
|
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) {
|
public Object deriveKey(JDBCStore store, Object value) {
|
||||||
|
|
Loading…
Reference in New Issue