Java Reference
In-Depth Information
public MyExampleCallback(Address deliveryAddress,
Date deliveryTime) {
this.deliveryAddress = deliveryAddress;
this.deliveryTime = deliveryTime;
}
B Saves delivery
information
C Tests for
equality
public boolean equals(Object other) {
if (other == null)
return false;
if (!(other instanceof MyExampleCallback))
return false;
MyExampleCallback x = (MyExampleCallback) other;
return deliveryAddress.equals(x.deliveryAddress)
&& deliveryTime.equals(x.deliveryTime);
}
public Object doInJdo(PersistenceManager pm) {
Map params = makeParameters(deliveryAddress,
deliveryTime);
Query query = pm.newQuery(Restaurant.class);
query.declareVariables("…");
query.declareImports("…");
return query.executeWithMap(params);
}
private Map makeParameters(Address deliveryAddress,
Date deliveryTime) {
return…;
}
}
Let's take a closer look at MyExampleCallback :
The constructor takes the delivery information as parameters and stores it in a field.
The equals() method returns true if the delivery information is the same in both
callbacks.
The doInJdo() method executes the query.
And here is an example of a repository that uses it:
D Executes
the query
B
C
D
public class JDORestaurantRepositoryImpl extends JdoDaoSupport
implements RestaurantRepository {
public JDORestaurantRepositoryImpl(JdoTemplate jdoTemplate) {
setJdoTemplate(jdoTemplate);
}
Search WWH ::




Custom Search