//logger.fine("Class Mapping Table: " + classMapping.getTable().getName());
Class filterTargetClass = classMapping.getMappedClass();
//logger.fine("Filter Target Class: " + filterTargetClass.getName());
QueryImpl query = new QueryImpl(mgr);
query.setClass(filterTargetClass);
query.setFilter(mapping.getFilter());
// We support the implicit "owner" parameter in filters.
// The owner refers to the object instance off which the
// collection field getter is being called. We need to add
// it to the parameters that we set on the query.
String parameters = mapping.getParameters();
ClassMapping ownerClassMapping = owner.getClassMapping();
Class ownerClass = ownerClassMapping.getMappedClass();
String ownerClassName = ownerClass.getName();
//ownerClassName = ownerClassName.substring(ownerClassName.lastIndexOf('.') + 1);
//logger.fine("OwnerClassName: " + ownerClassName);
if (mapping.getImports() != null) {
query.declareImports(mapping.getImports());
}
if (parameters == null || parameters.equals("")) {
// No parameters, just this owner param
parameters = ownerClassName + " owner";
}
else {
// Append this owner param to the existing parameters
parameters += ", " + ownerClassName + " owner";
}
logger.fine("Modified Parameters: " + parameters);
query.declareParameters(parameters);
if (mapping.getVariables() != null) {
query.declareVariables(mapping.getVariables());
}
if (mapping.getOrdering() != null) {
query.setOrdering(mapping.getOrdering());
}
query.compile();
//logger.fine("Filter Query: " + query);
BoundExpression bound = query.getBoundExpression();
int paramCount = 0;
if (args != null) {
while (paramCount < args.length) {
bound.bindParameter(paramCount, args[paramCount]);
++paramCount;