I have a couple of related entities in a relational DB:
@Entity
public class A {
@Id
@Column(name = "id" ...)
private UUID id;
@OneToMany(mappedBy = "a")
private Set<B> bs;
}
and
@Entity
public class B {
@Id
@Column(name = "id" ...)
private UUID id;
@ManyToOne
@JoinColumn(name = "a_id")
private A a;
}
So I have a B Repository
@Repository
public interface BRepository extends JpaRepository<B, UUID> {
List<B> findByA(A a);
}
And id like to have a query by which I obtain the all Bs with the same A. I'm used to have an a_id column in B, not the whole entity. I don't know how to manage this, nor with a JPA query nor with a NamedQuery.
Many thanks in advance!
Luis