// Clients
List<Client> savedClients = new ArrayList<Client>();
for (Client client : clients)
{
Client savedClient = clientRepository.save(client);
savedClients.add(savedClient);
logger.info("Persisted {}", client);
}
// Projects
List<Project> savedProjects = new ArrayList<Project>();
for (Project project : projects)
{
Client savedClient = savedClients.get(random.nextInt(clients.size()));
project.setClient(Ref.create(savedClient));
Project savedProject = projectRepository.save(project);
savedProjects.add(savedProject);
logger.info("Persisted {}", project);
}