Search in sources :

Example 11 with SongLocal

use of org.apache.openejb.test.entity.cmr.onetomany.SongLocal in project tomee by apache.

the class OneToManyTests method test01_BGetAExistingAB.

public void test01_BGetAExistingAB() throws Exception {
    resetDB();
    beginTransaction();
    try {
        SongLocal song = findSong(11);
        ArtistLocal artist = song.getPerformer();
        assertNotNull(artist);
        assertEquals(new Integer(1), artist.getId());
        assertEquals("value1", artist.getName());
        song = findSong(22);
        artist = song.getPerformer();
        assertNotNull(artist);
        assertEquals(new Integer(1), artist.getId());
        assertEquals("value1", artist.getName());
    } finally {
        completeTransaction();
    }
}
Also used : ArtistLocal(org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal) SongLocal(org.apache.openejb.test.entity.cmr.onetomany.SongLocal)

Example 12 with SongLocal

use of org.apache.openejb.test.entity.cmr.onetomany.SongLocal in project tomee by apache.

the class OneToManyTests method test02_ASetBDropExisting.

public void test02_ASetBDropExisting() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final ArtistLocal artist = findArtist(1);
        artist.setPerformed(new HashSet<SongLocal>());
    } finally {
        completeTransaction();
    }
    assertUnlinked(1);
}
Also used : ArtistLocal(org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal) SongLocal(org.apache.openejb.test.entity.cmr.onetomany.SongLocal)

Example 13 with SongLocal

use of org.apache.openejb.test.entity.cmr.onetomany.SongLocal in project tomee by apache.

the class OneToManyTests method test10_RemoveRelationships.

public void test10_RemoveRelationships() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final SongLocal song = findSong(11);
        final ArtistLocal artist = song.getPerformer();
        final Set<SongLocal> songs = artist.getPerformed();
        assertTrue(songs.contains(song));
        song.remove();
        assertFalse(songs.contains(song));
    } finally {
        completeTransaction();
    }
    assertLinked(1, 22);
    assertUnlinked(2);
}
Also used : ArtistLocal(org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal) SongLocal(org.apache.openejb.test.entity.cmr.onetomany.SongLocal)

Example 14 with SongLocal

use of org.apache.openejb.test.entity.cmr.onetomany.SongLocal in project tomee by apache.

the class OneToManyTests method createSong.

private SongLocal createSong(final int songId) throws CreateException {
    final SongLocal song = songLocalHome.create(songId);
    song.setName("value" + songId);
    return song;
}
Also used : SongLocal(org.apache.openejb.test.entity.cmr.onetomany.SongLocal)

Example 15 with SongLocal

use of org.apache.openejb.test.entity.cmr.onetomany.SongLocal in project tomee by apache.

the class OneToManyTests method test04_ASetBNewAB.

public void test04_ASetBNewAB() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final ArtistLocal artist = findArtist(2);
        final SongLocal song = findSong(22);
        final Set<SongLocal> songSets = new HashSet<SongLocal>();
        songSets.add(song);
        artist.setPerformed(songSets);
    } finally {
        completeTransaction();
    }
    assertLinked(2, 22);
}
Also used : ArtistLocal(org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal) SongLocal(org.apache.openejb.test.entity.cmr.onetomany.SongLocal) HashSet(java.util.HashSet)

Aggregations

SongLocal (org.apache.openejb.test.entity.cmr.onetomany.SongLocal)41 ArtistLocal (org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal)36 ResultSet (java.sql.ResultSet)14 HashSet (java.util.HashSet)14 Set (java.util.Set)10 ConcurrentModificationException (java.util.ConcurrentModificationException)8 Iterator (java.util.Iterator)8 Connection (java.sql.Connection)6 Statement (java.sql.Statement)6 SQLException (java.sql.SQLException)2