Готовая 3
This commit is contained in:
parent
3bc5b4440e
commit
83673a42b8
@ -63,7 +63,10 @@ public class MangaService {
|
||||
public List<Reader> getReader(Long id) {
|
||||
//em.createNativeQuery("delete from Mangas_Readers where MANGA_FK = " + manga.getId() + " AND READER_FK = "+ readerId).executeUpdate();
|
||||
//SELECT b FROM Book b WHERE ?1 MEMBER OF b.genres
|
||||
final List<Reader> listReader = em.createQuery("select r from Reader r where " + id + " MEMBER OF r.mangas", Reader.class).getResultList();
|
||||
final Manga currentManga = em.find(Manga.class, id);
|
||||
final List<Reader> listReader = em.createQuery("select r from Reader r where :currentManga MEMBER OF r.mangas", Reader.class)
|
||||
.setParameter("currentManga", currentManga)
|
||||
.getResultList();
|
||||
return listReader;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class ReMangaTest {
|
||||
@Autowired
|
||||
@ -44,9 +46,10 @@ public class ReMangaTest {
|
||||
|
||||
Reader r4 = readerService.findReader(r1.getId());
|
||||
log.info(r4.getMangas().toString());
|
||||
//List<Reader> listReader = mangaService.getReader(m1.getId());
|
||||
//log.info(listReader);
|
||||
Assertions.assertEquals(2, mangaService.getReader(m1.getId()).size());
|
||||
List<Reader> listReader = mangaService.getReader(m1.getId());
|
||||
log.info(listReader.toString());
|
||||
Assertions.assertEquals(true, mangaService.getReader(m1.getId()).contains(r4));
|
||||
Assertions.assertEquals(true, mangaService.getReader(m1.getId()).contains(r2));
|
||||
readerService.deleteAllReaders();
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
|
Loading…
Reference in New Issue
Block a user