everyone. I have 3 tables: 1:
id,
table2_id
2:
id,
param1
3:
id,
table1_id,
param2
I have this sql code:
select * from table1 g
left join table2 f on g.table2_id = f.id
left join table3 k on k.table1_id = g.id
where f.param1 = '1272' or k.param2= '1272'
my sql code means, that i would like take all objects from table1 by param '1272', that I'm using for other tables.
my @Query looks like:
@Query("select p from Table1 p " +
"left join p.table2 t " +
"left join p.table3 b " +
"where (:param != null or t.param1 = :param or b.param2 = :param")
Page<Table1> searchByParam(@Param("param") String param, Pageable pageable);
But Its given me wrong result. What am I doing wrong?