Reputation: 522
I have two entities
1)
Person
int id
String name
@JoinColumn(name = "person_id")
List<Email> emailList;
2)
Email
int id
String emailAddress
In Email table, I have three columns - id
, emailAddress
, person_id
.
My question is - can I write a SpringData method in EmailRepository
like - findByEmailAddressAndPersonIdNotNull(String emailAddress)
or do I have to write a custom @Query
?
I need to find email by column person_id.
Upvotes: 0
Views: 414
Reputation: 81882
findByEmailListEmailAddressAndPersonIdNotNull(String emailAddress)
or findByEmailList_EmailAddressAndPersonIdNotNull(String emailAddress)
should work.
Upvotes: 1