result = ps.executeQuery();
ArrayList<Association> arrayList = new ArrayList<Association>();
// Read all results first
while (result.next()) {
Association association = new Association();
association.setSourcePath(toPath);
association
.setDestinationPath(result.getString(DatabaseConstants.TARGETPATH_FIELD));
association.setAssociationType(
result.getString(DatabaseConstants.ASSOCIATION_TYPE_FIELD));
arrayList.add(association);
}
// Then add associations
for (Association association : arrayList) {
addAssociation(toPath, association.getDestinationPath(),
association.getAssociationType());
}
} catch (SQLException e) {
String msg = "SQLException occurred during copyAssociations";
log.error(msg, e);
throw new RegistryException(msg, e);