final PersistenceQueryData criteriaData = encoderDecoder.encodePersistenceQuery(persistenceQuery);
return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<ObjectAdapter[]>() {
@Override
public ObjectAdapter[] execute() {
final FindInstancesRequest request = new FindInstancesRequest(getAuthenticationSession(), criteriaData);
final FindInstancesResponse response = serverFacade.findInstances(request);
final ObjectData[] instancesAsObjectData = response.getInstances();
final ObjectAdapter[] instances = new ObjectAdapter[instancesAsObjectData.length];
for (int i = 0; i < instancesAsObjectData.length; i++) {
instances[i] = encoderDecoder.decode(instancesAsObjectData[i]);
}
return instances;