I have a parent Table, called "PN", which in it's entity contains a list of another Entity "PnDett", which is related to the first table. 
I want to execute a query that will give me the list of PN with my where condition, but that will filter the list of "PnDett" also based on a where condition. 
How can i achieve this? 

This is the PN mapping:

```
@Entity
@Table(name = "PN")
public class Pn implements java.io.Serializable {

private static final long serialVersionUID = 2556879508428749494L;

@Id
@Column(name="ID_PN", unique = true, nullable = false)
private BigDecimal idPN;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="DATA_DOC")
private Date dataDoc;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="DATA_COMP_BANC")
private Date dataCompBanc;

@Column(name="STATO_PN")
private String statoPN;

@Column(name="TESTO_TESTATA")
private String testoTestata;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="DATA_INVIO_SAP")
private Date dataInvioSap;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="DATA_INS")
private Date dataIns;

@Column(name="ID_UTENTE_AGG")
private BigDecimal idUtenteAgg;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="DATA_CONTABILE")
private Date dataContabile;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="DATA_REND_INTEGR")
private Date dataRendIntegr;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="DATA_AGG")
private Date dataAgg;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "pn")
private Set<PnDett> pnDetts = new HashSet<>(0);

```

This is the PnDett mapping:

```
@Entity
@Table(name = "PN_DETT")
public class PnDett implements java.io.Serializable {
private static final long serialVersionUID = 2556879508428749494L;

@Id
@Column(name="ID_PN_DETT", unique = true, nullable = false)
private BigDecimal idPNDett;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="ID_PN", nullable=false)
private Pn pn;

@OneToOne
@JoinColumn(name="ID_DOM_TIPO_SCRITTURA")
private DomTipoScrittura domTipoScrittura;

@Column(name="TIPO_DOCUMENTO")
private String tipoDocumento;

@Column(name="ID_CALCOLO")
private String idCalcolo;

@Column(name="CONTO_COGE")
private String contoCoge;

@Column(name = "IMPORTO_AVERE")
private BigDecimal importoAvere;

@Column(name = "IMPORTO_DARE")
private BigDecimal importoDare;

@OneToOne
@JoinColumn(name="ID_UTENTE")
private Utente utente;

@Column(name = "DATA_INS")
private Date dataIns;

@Column(name = "TIPO_DETTAGLIO")
private String tipoDettaglio;

@Column(name = "SE_CANC")
private Integer seCancellato;

```

In HQL, i wrote this query "select \* from Pn firstNote where firstNote.dataContabile = (a param i put myself, in this case 20 april 2020) and firstNote.pnDetts.seCancellato = (a param i put myself, in this case 0) and firstNote.pnDetts.importoDare <> 0 or firstNote.pnDetts.importoAvere <> 0"

The results are, quite frankly, a mess. I have only two lines in my PN table that have the parameter dataContabile set at 20 april 2020, and yet i get 18 results, and the results are an Object[] which somehow containes both entities. Inside the PN object i do have the pnDetts list filtered to match the date i'm searching them for, but the other filters don't even work. How can i fix this mess? Ideally, my result should be a list of two PN objects that have the pnDetts list filtered, but i don't know how to achieve this.

Edit: 
Ok, i've made an SQL query and found out that the PnDett lines related to that date that have either importoDare <> 0 or importoAvere<>0 are exactly 18, that's why i get 18 sets of objects[]. But how can i have just two PN objects, with the list inside filtered instead?