em.getTransaction().begin();
try {
Artist artist = artistRepository.findByName("Whitney Houston").iterator().next();
Release release = releaseRepository.findByName("The Bodyguard (Original Soundtrack Album)").iterator().next();
CreditEntity credit = new CreditEntity();
credit.setArtistPersonId(artist.getId());
credit.setReleaseRecordingWorkId(release.getId());
credit.setType("Important contributor");
credit.setLastUpdated(new Date());
credit.setLastUpdatedBy("JUnit");
creditRepository.create(credit);
Collection<CreditEntity> credits = creditRepository.findCreditsForReleaseRecordingWork(release);
assert credits != null;
assert credits.size() == 1;
credit = credits.iterator().next();
assert credit != null;
assert credit.getLastUpdated() != null;
assert credit.getLastUpdatedBy() != null;
assert credit.getType().equals("Important contributor");
artist = artistRepository.findById(credit.getArtistPersonId());
assert artist != null;
assert artist.getName().equals("Whitney Houston");
release = releaseRepository.findById(credit.getReleaseRecordingWorkId());
assert release != null;
assert release.getName().equals("The Bodyguard (Original Soundtrack Album)");
}catch (Exception e) {
em.getTransaction().rollback();