1
我有一個如下所示的控制器。彈出數據JPA過濾
public String getAccountsFilter(
@PathVariable("cardHolderId") String cardHolderId,
@RequestParam(value = "accountType", required = false) String accountType,
@RequestParam(value = "name", required = false) String name)
的AccountEntity是如下
public class AccountEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String accounttype;
private Date endDate;
private boolean active;
private PlanEntity planEntity;
private Set<TransactionEntryEntity> transactionEntry = new HashSet<TransactionEntryEntity>();
我爲id
和accountType
其易於使用findByIdAndAccountType()
方法過濾,並自動生成查詢。
但是如果我想使用id
和name
這是Plan (AccountEntity.PlanEntity.name)
屬性過濾,它不是簡單的,因爲name
是從子表。我如何處理這個標準?
您可以註釋方法'方法之一以下注釋findByIdAndPlanEntityName 'AccountEntityRepository'中使用JPQL或連接AccountEntity和PlanEntity的SQL查詢,並返回符合條件的AccountEntity對象列表。這可能會幫助您http://www.oracle.com/technetwork/articles/vasiliev-jpql-087123.html。 – Vikdor