Java Reference
In-Depth Information
Listing 5.4
ExecuteNamedQueryWithMapCallback
public class ExecuteNamedQueryWithMapCallback implements
JdoCallback {
private String queryName;
private Map parameters;
private Class type;
public ExecuteNamedQueryWithMapCallback
bbbbbbbbbbbb (String queryName,
Map parameters,
Class type) {
this.queryName = queryName;
this.parameters = parameters;
this.type = type;
}
B Creates ExecuteNamedQuery
WithMapCallback
C Tests for
equality
public boolean equals(Object other) {
if (other == null)
return false;
if (!(other instanceof ExecuteNamedQueryWithMapCallback))
return false;
ExecuteNamedQueryWithMapCallback x =
(ExecuteNamedQueryWithMapCallback) other;
return queryName.equals(x.queryName)
&& parameters.equals(x.parameters)
&& type.equals(x.type);
}
public int hashCode() {
return queryName.hashCode()
^ parameters.hashCode()
^ type.hashCode();
}
D Executes the
named query
public Object doInJdo(PersistenceManager pm)
throws JDOException {
Query query = pm.newNamedQuery(type, queryName);
return query.executeWithMap(parameters);
}
}
Let's take a closer look at ExecuteNamedQueryWithMapCallback :
Search WWH ::




Custom Search