I have two entities :
A:
class A {
@Id
Long id;
@OneToMany(fetch = FetchType.LAZY)
List<B> listOfB;
}
and class B :
class B {
@Id
Long id;
@ManyToOne(fetch = FetchType.LAZY)
A a;
}
now in my spring data repo I'm creating a query like :
@Query("SELECT a FROM A a INNER JOIN a.listOfB b WHERE b.id = :id")
The problem is, that the query is executed and returns some A objects, but when I want to access the listOfB
I'm getting a NullPointerException
...
A a = aRepository.findByOwnQuery(id);
a.getListOfB().size(); -> NullPointerException