mirror of
https://github.com/apache/openjpa.git
synced 2025-02-21 17:45:51 +00:00
Help Catalina committing OPENJPA-313.r564688.patch
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@565845 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
99ecf9564b
commit
26b0e49845
@ -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,33 @@ public class ClassMapping
|
||||
}
|
||||
}
|
||||
Object oid = ApplicationIds.fromPKValues(vals, cls);
|
||||
if (!subs && oid instanceof OpenJPAId)
|
||||
((OpenJPAId) oid).setManagedInstanceType(cls.getDescribedType());
|
||||
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())) {
|
||||
// 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 discriminator value.
|
||||
// If the discriminator value is not present or invalid,
|
||||
// ignore any exceptions being thrown.
|
||||
// The discriminator value can potentially be null in the
|
||||
// database because the mapping tool does not enforce the
|
||||
// discriminator column 'not null'.
|
||||
// We can not prevent other non-jpa applications from inserting
|
||||
// a null or invalid discriminator value.
|
||||
res.startDataRequest(cls.getDiscriminator());
|
||||
try {
|
||||
type = cls.getDiscriminator().getClass(store, cls, res);
|
||||
((OpenJPAId) oid).setManagedInstanceType(type);
|
||||
} catch (Exception e) {}
|
||||
res.endDataRequest();
|
||||
}
|
||||
}
|
||||
return oid;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user