The new method in JpaRepository generates new objects and configures its constructor
JPA has some rules for field naming. It is recommended to use camel case naming. If the following method will report an error and there is no clear error message, please check whether the field is legal first! ! ! ! !
The following is the example code:
JpaRepository:
@Transactional
public interface PayeeDataRepo extends JpaRepository<PayeeData, String> {
@Query("select new com.stylefeng.guns.workday.bean.PayeeData(p.id,p.name,p.bankAccountNumberEncode,p.adhocPayeeID,p.isDomestic,p.bankAccountName ) from PayeeData p")
List<PayeeData> finddAllNoBankNumber();
}
PayeeData Bean:
public class PayeeData implements Serializable {
public PayeeData() {
}
public PayeeData(String id, String name, String bankAccountNumberEncode, String adhocPayeeID, Integer isDomestic, String bankAccountName) {
this.id = id;
this.name = name;
this.bankAccountNumberEncode = bankAccountNumberEncode;
this.adhocPayeeID = adhocPayeeID;
this.isDomestic = isDomestic;
this.bankAccountName = bankAccountName;
}
}