mirror of https://github.com/apache/openjpa.git
Help Catalina committing OPENJPA-313.2.patch
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@566006 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e59b9deab9
commit
c014c92538
|
@ -30,6 +30,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||
import org.apache.openjpa.jdbc.meta.strats.NoneClassStrategy;
|
||||
|
@ -189,8 +190,34 @@ public class ClassMapping
|
|||
}
|
||||
}
|
||||
Object oid = ApplicationIds.fromPKValues(vals, cls);
|
||||
if (!subs && oid instanceof OpenJPAId)
|
||||
((OpenJPAId) oid).setManagedInstanceType(cls.getDescribedType());
|
||||
|
||||
/**
|
||||
* For polymorphic relations,
|
||||
* the type field in the oid is initially set to base type.
|
||||
* If the discriminator value is preset in the current result,
|
||||
* then the type field needs reset based on the discriminator value.
|
||||
* If the discriminator value is not present or invalid,
|
||||
* ignore any exceptions being thrown.
|
||||
*/
|
||||
if (oid instanceof OpenJPAId) {
|
||||
Class type = cls.getDescribedType();
|
||||
if (!subs)
|
||||
// non-polymorphic relations
|
||||
((OpenJPAId) oid).setManagedInstanceType(type);
|
||||
else if (cls.getDiscriminator() != null
|
||||
&& !StringUtils.equals("none",
|
||||
cls.getDiscriminator().getStrategy().getAlias())) {
|
||||
// polymorphic relations
|
||||
res.startDataRequest(cls.getDiscriminator());
|
||||
try {
|
||||
type = cls.getDiscriminator().getClass(store, cls, res);
|
||||
((OpenJPAId) oid).setManagedInstanceType(type, true);
|
||||
} catch (Exception e) {
|
||||
// intentionally ignored
|
||||
}
|
||||
res.endDataRequest();
|
||||
}
|
||||
}
|
||||
return oid;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,14 @@ public abstract class OpenJPAId
|
|||
this.subs = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the exact type of the described instance once it is known.
|
||||
*/
|
||||
public void setManagedInstanceType(Class type, boolean subs) {
|
||||
this.type = type;
|
||||
this.subs = subs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identity value as an object.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue