I have the following entities:
@ Entity
@ Table(“table_x”)
public class X{
@ Id
@ GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ ManyToOne
private Y y;
}
@ Entity
@ Table(“table_y”)
public class Y{
@ Id
@ GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}
and a repository
@ Repository
public interface XRepository extends JpaRepository<X, Long>, JpaSpecificationExecutor{
@ Query(value= “select x.* from X x where x.y in :yList”)
List getX(List yList);
}
when trying to call getX from XRepository while table_y is empty, it throws:
Method threw ‘org.springframework.dao.InvalidDataAccessResourceUsageException’ exception.
could not extract ResultSet; SQL [n/a]
if table_y has records in the database, everything works fine