use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyTests method createArtist.
private ArtistLocal createArtist(final int songId) throws CreateException {
final ArtistLocal artist = artistLocalHome.create(songId);
artist.setName("value" + songId);
return artist;
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyTests method resetDB.
private synchronized void resetDB() throws Exception {
final Connection connection = ds.getConnection();
Statement statement = null;
try {
statement = connection.createStatement();
try {
statement.execute("DELETE FROM Artist");
} catch (final SQLException ignored) {
}
try {
statement.execute("DELETE FROM Song");
} catch (final SQLException ignored) {
}
} finally {
close(statement);
close(connection);
}
final ArtistLocal artist1 = createArtist(1);
createArtist(2);
final SongLocal song1 = createSong(11);
final SongLocal song2 = createSong(22);
song1.setPerformer(artist1);
song2.setPerformer(artist1);
song1.setComposer(artist1);
song2.setComposer(artist1);
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyTests method test09_BSetAExistingANewB.
public void test09_BSetAExistingANewB() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(1);
final SongLocal song = createSong(33);
song.setPerformer(artist);
} finally {
completeTransaction();
}
assertLinked(1, 11, 22, 33);
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyTests method test00_AGetBExistingAB.
public void test00_AGetBExistingAB() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(1);
final Set bSet = artist.getPerformed();
assertEquals(2, bSet.size());
for (final Object value : bSet) {
final SongLocal song = (SongLocal) value;
if (song.getId().equals(11)) {
assertEquals("value11", song.getName());
} else if (song.getId().equals(22)) {
assertEquals("value22", song.getName());
} else {
fail();
}
}
} finally {
completeTransaction();
}
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyTests method test05_BSetANewAB.
public void test05_BSetANewAB() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(2);
final SongLocal song = findSong(22);
song.setPerformer(artist);
} finally {
completeTransaction();
}
assertLinked(2, 22);
}
Aggregations