How to create a JPAContainer Filter for Foreign Keys?

Hi,

I have 2 tables and use each a JPAContainer for user input to database binding.
When I select a row in table 1, I want to filter table 2 according to the selection. Imagine table1 shows all persons in the DB, and on selection I only want table2 to show the payments of person that was selected in table1.

For sure I have to create a Filter and use

paymentContainer.addContainerFilter(filter);

But how can I filter for a personID (foreign key) inside the payments?

Filter filter = new Compare.Equal("person.id", selectedPersonId); //something similar to this??

Problem: I don’t have references from payments to persons. I only have the oneway from Person > Payment. How can I filter for foreign keys?

class Person {
    @Id
    Long id;

    @OneToMany
    List<Payment> payments;
}

class Payment {
    int amount;
}

It could help if you make the relationship be bidirectional in JPA:

@Entity class Person
  {
   @Id int id;
   @OneToMany(mappedBy="person")
   Collection<Payment> listOfPayment;
  }
@Entity class Payment
  {
   @Id int id;
   @ManyToOne
   Person person;
  int amount
}

Then you can add a filter by “Person” in the second container.

I use Eclipselink and I noticed that when I have bidirectional relationships, I can use “Table.column” properties in the filtrs, and they work, for example:

new SimpleStringFilter(“person.name”, “Jhon”, true, false)
Might work as a filter for the Payments container, and searching for payments of people named “jhon”
a compare.equal filter on person.id would be trivial.

Yes I know I could add bidirectionality, but I’d like to to a filter without having to modify my domain model.