79278389

Date: 2024-12-13 12:57:01
Score: 1
Natty:
Report link

I see you are using @Inheritance(JOINED) annotation so the subclasses got foreign key column(s) which primary key of superclass.

I am going to recommend you solution on Spring Data JPA. On implementation, I didn't see any problem so I can help you for implement @Repository interface.

@Repository
public interface AbstractCompanyRepository extends JpaRepository<AbstractCompany, Long> {
    @Query("SELECT DISTINCT a FROM AbstractCompany a " +
           "JOIN Company c ON c.id = a.id " +
           "JOIN Invitation i ON i.id = a.id " +
           "WHERE c.city = 'London' " +
           "AND NOT i.expired")
    List<AbstractCompany> getLondonAndNotExpired();
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Repository
  • Low reputation (1):
Posted by: Ali İhsan TAŞDELEN