public void setAttributeValueInObject(Object object, Object value) {
if (!(object instanceof ObjectLevelReadQuery)) {
return;
}
ObjectLevelReadQuery query = (ObjectLevelReadQuery)object;
Expression expression = (Expression)value;
if (expression != null) {
expression = expression.rebuildOn(query.getExpressionBuilder());
}
query.setSelectionCriteria(expression);
}
});
expressionMapping.setReferenceClass(Expression.class);
expressionMapping.setXPath(getSecondaryNamespaceXPath() + "criteria");
descriptor.addMapping(expressionMapping);
XMLCompositeCollectionMapping argumentsMapping = new XMLCompositeCollectionMapping();
// Handle translation of argument lists to query-arguments.
argumentsMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
DatabaseQuery query = (DatabaseQuery)object;
Vector arguments = query.getArguments();
Vector types = query.getArgumentTypeNames();
Vector values = query.getArgumentValues();
Vector queryArguments = new Vector(arguments.size());
for (int index = 0; index < arguments.size(); index++) {
QueryArgument queryArgument = new QueryArgument();
queryArgument.setKey(arguments.get(index));
if (!types.isEmpty()) {
queryArgument.setTypeName((String)types.get(index));
}
if (!values.isEmpty()) {
queryArgument.setValue(values.get(index));
}
queryArguments.add(queryArgument);
}
return queryArguments;
}
public void setAttributeValueInObject(Object object, Object value) {
DatabaseQuery query = (DatabaseQuery)object;
Vector queryArguments = (Vector)value;
Vector arguments = NonSynchronizedVector.newInstance(queryArguments.size());
Vector types = NonSynchronizedVector.newInstance(queryArguments.size());
Vector values = NonSynchronizedVector.newInstance(queryArguments.size());
for (int index = 0; index < queryArguments.size(); index++) {
QueryArgument queryArgument = (QueryArgument)queryArguments.get(index);
arguments.add(queryArgument.getKey());
if (queryArgument.getValue() != null) {
values.add(queryArgument.getValue());
}
if (queryArgument.getType() != null) {
types.add(queryArgument.getType());
}
}
query.setArguments(arguments);
if (!types.isEmpty()) {
query.setArgumentTypes(types);
}
if (!values.isEmpty()) {
query.setArgumentValues(values);
}
}
});
argumentsMapping.setAttributeName("argumentsMapping");
argumentsMapping.setXPath(getSecondaryNamespaceXPath() + "arguments/" + getSecondaryNamespaceXPath() + "argument");