I want an ask for you. I wrote a JPQL query like this (I write the part that I want to bring to your attention):
SELECT DISTINCT
e
FROM
MyEntity e
JOIN e.myEntityTwo s
...
WHERE
s.id = :id
...
MyEntity is something like this:
@Entity
@Table(name="DBTABLE")
public class MyEntity implements Serializable {
...
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="ID_TABLE")
private MyEntityTwo myEntityTwo;
...
//getter and setter
}
So, when I execute query, this returns me also myEntityTwo object for some id filter (but..it was not lazy?!) and does not return any myEntityTwo object for others one. The strange thing is that the sql generated query (I see it from the stacktrace) looks the same in both cases! I'm using Oracle and JPA (Hibernate provider) I can not explain why?!