0

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

ldepablo
  • 424
  • 6
  • 19

1 Answers1

0

As already answered, the proposed code should already work but it didn't... The fix that worked for me was

List<B> findByA_Id(UUID id);

Table_Field references field field to table Table.

ldepablo
  • 424
  • 6
  • 19