Help pls with SQL

Hi everybody,

newbie here.

Got my SQL working in SQL Editor, and cnt understand how translate this into JPQL so i can use it in vaadin.

Have two tables LieferantProdukt and Produkt, they are in relation so Every LieferantProdukt have 1 Produkt, and 1 produkt have many LieferantProdukts.

So made my sql:

select * from Produkt p, lieferantprodukt lp where p.ID = lp.PRODUKTID and lp.LIEFERANTID = 3;

This is some how some small SQL i used to do all my life. Sadly i dont know how to translate this into JPQL so i can use it in the queries like this:


String query = "SELECT p FROM Produkt AS p, LieferantProdukt AS lp WHERE p.id = lp.produktid and lp.lieferantid :=lieferantid";
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("lieferantid", this.id);
List<Produkt> elements = FacadeFactory.getFacade().list(query, parameters);

This query i did make always some exceptons and i get no results :slight_smile: Please help!

It’s better you post the exceptions also.
The query is wrong. Below is correct section.


lp.lieferantid = :lieferantid 

Thank you very much :slight_smile: !!

Problem Solved!