Home Native Query is not working in JPA: why?
Reply: 0

Native Query is not working in JPA: why?

user1326 Published in March 23, 2018, 10:15 pm

I want to make a query that returns a list of objects from a database. There seem to be something wrong with the query because of the error : Encountered 'by' at line x column xx. I don't know what is wrong about the query. Can someone pls help.

public List<Film> getFilmsVanRegisseur(String voornaam, String achternaam){

        List<Film> l;
        //de fout zit in de query
        Query q = em.createNativeQuery(""
                + "select films.filmnaam,films.uitgavejaar "
                + "from films "
                + "inner join regisseurs on films.regisseur = regisseurs.id "
                + "inner join filmmedewerkers on filmmedewerkers.id = regisseurs.id "
                + "where filmmedewerkers.voornaam = ? and filmmedewerkers.achternaam = ?"
                + "group by films.filmnaam, films.uitgavejaar", Film.class);
        q.setParameter(1, voornaam);
        q.setParameter(2, achternaam);

        l = q.getResultList();

        return l;


The tables in the database are Films, Filmmedewerkers and Regisseur which is a specific type of Filmmedewerkers. I want to make a query that returns a list of Films from a Regisseur with a voornaam and achternaam (as you can see in the parameters) the tables are correctly connected.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.295522 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO