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

Native Query is not working in JPA: why?

Thomas Neuser
1#
Thomas Neuser Published in 2017-12-07 15:39:23Z

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.318409 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO