Come da indicazioni ho creato la classe di appoggio che mette in relazione la tabella Book ed Autore
codice:
public class BookAndAutore {
private String title;
private String author;
private int eta;
public BookAndAutore(String title, String author, int eta) {
this.title = title;
this.author = author;
this.eta = eta;
}
}
Nel creare il service però trovo già un inghippo. Il metodo createQuery non accetta la classe e mi restituisce errore in compilazione:
The method createQuery(String) in the type EntityManager is not applicable for the arguments
Ecco il metodo:
codice:
public List<BookAndAutore> getBookAutore() {
String queryStr = "select it.miaapp.entity.BookAndAutore(p.title, p.author, c.eta) from books p, autore c where (p.author = c.author)";
TypedQuery<BookAndAutore> query = em.createQuery(queryStr, BookAndAutore.class);
List<BookAndAutore> results = query.getResultList();
}
Qualcuno ha qualche idea?
Grazie