使用spring jpa 的时候需要自己写个查询但是不会,
请教下:
@Entity
class B{
@Id
@GeneratedValue
private Integer id;
private String atrrB;
@OneToMany(mappedBy = "b" )
private List<A> as;
...
/* id,atrrB,as的Setter&Getter */
}
@Entity
class A{
@Id
@GeneratedValue
private Integer id;
@ManyToOne
@JoinColumn(a_id)
private B b ;
private String atrrA;
...
/* id,atrrA,b的Setter&Getter */
}
interface ARepository extends JpaRepository <A,Integer>{
@Query("不会啊")
public List<A> getReslut(String atrrA_key, String atrrB_key);
}
那个sql语句不会,希望结果可以得到所有A表格里所有atrrA属性like查询方法第一个参数And A表格里的b.atrrB属性 like 查询方法的第二个参数的所有条目。