*/
private void addDiscriminator(QueryData qd, ClassLoaderResolver clr) {
if (qd.acmd.hasDiscriminatorStrategy()) {
String className = qd.acmd.getFullClassName();
boolean includeSubclasses = query.isSubclasses();
DatastoreManager storeMgr = getStoreManager();
String discriminatorPropertyName = EntityUtils.getDiscriminatorPropertyName(storeMgr.getIdentifierFactory(),
qd.acmd.getDiscriminatorMetaDataRoot());
// Note : we always restrict the discriminator since the user may at some later point add other classes
// to be persisted here, or have others that have data but aren't currently active in the persistence process
List<Object> discriminatorValues = new ArrayList<Object>();
discriminatorValues.add(qd.acmd.getDiscriminatorValue());
if (includeSubclasses) {
for (String subClassName : storeMgr.getSubClassesForClass(className, true, clr)) {
AbstractClassMetaData subCmd = storeMgr.getMetaDataManager().getMetaDataForClass(subClassName, clr);
discriminatorValues.add(subCmd.getDiscriminatorValue());
}
}
qd.primaryDatastoreQuery.addFilter(discriminatorPropertyName, Query.FilterOperator.IN, discriminatorValues);