I have 2 tables with beans like above attached.
I build a little restful with spring with an output JSON file.
I did try to do a select with HQL language to filter 1 row for article '046'.
The output JSON come back 3 rows and not 1 rows like the data.
Someone can help me?
Thanks so much!
DATA:
Prelievo(id)   Row(Id)  Article
1082040        1        066   
1082040        2        066 
1082040        3        046   
         
BEANS:
public class RighePrelievo implements Serializable {
@Id
@Column(name = "ABAMNB")
private int id;
@Id
@Column(name = "ABALNB")
private int rigaPrelievo;
@Column(name = "ABAJCD")
private String articolo;
@JsonIgnore
@ManyToOne
@JoinColumn(name = "ABAMNB", insertable = false, updatable = false)
private Prelievo prelievo;
 ...getter and setter
}
public class Prelievo implements Serializable {
@Id
@Column(name = "AHAMNB")
private int id;
@OneToMany(mappedBy = "prelievo")
private List<RighePrelievo> righePrelievo = new ArrayList<>();
 ...getter and setter  
 }
HQL HIBERNATE QUERY:
 String articolo = "046";
List<Prelievo> firstFilterPrelievi = (List<Prelievo>) sessionFactory.getCurrentSession()
                .createQuery(
                        " select distinct p from "
                        + " Prelievo  p "
                        + " left join "
                        + " RighePrelievo r"
                        + " on p.id=r.id"
                        + " where "
                        + " r.articolo = :articolo "
                )
                .setParameter("articolo", articolo)
                .list();
OUTPUT JSON:
[
    {
        "id": 1082040,
        "righePrelievo": [
            {
                "id": 1082040,
                "rigaPrelievo": 1,
                "articolo": "066"
            },
            {
                "id": 1082040,
                "rigaPrelievo": 2,
                "articolo": "066"
            },
            {
                "id": 1082040,
                "rigaPrelievo": 3,
                "articolo": "046"
            }
        ]
    }
]