I recently upgraded Spring Boot from 1.5.2 Release to Spring Boot 2.1.3 Release. And after that my application does not run because of Caused by: org.springframework.data.mapping.PropertyReferenceException: No property getPayments found for type DailyPaymentOrgFunc!
Here is my entity :
import lombok.Data;
import org.hibernate.annotations.NamedNativeQuery;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Date;
@Data
@Entity
@NamedNativeQuery(name = Function.ORG_FUNC_NAME,query = Function.ORG_FUNC,
callable = true,resultClass = DailyPaymentOrgFunc.class)
public class DailyPaymentOrgFunc{
@Id
@Column(name = "RECEIPT_NUMBER")
private String receiptNumber;
@Column(name = "AMOUNT")
private Float amount;
@Column(name = "SERVICE_CODE")
private Integer serviceCode;
@Column(name = "PAYMENT_DATE")
private Date paymentDate;
@Column(name = "PAYMENT_TRN")
private String paymentTrn;
@Column(name = "ORG_CODE")
private Integer orgCode;
}
Repository :
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface DailyPaymentOrgRepository extends JpaRepository<DailyPaymentOrgFunc,String> {
List<DailyPaymentOrgFunc> getPayments(@Param("orgCode") Integer orgCode);
}
Constant Class :
public class Function {
public static final String ORG_FUNC_NAME = "DailyPaymentOrgFunc.getPayments";
public static final String ORG_FUNC ="{ ? = call DAILY_PAYMENT_FUNC(null,2,:orgCode,null)}";
private Function() throws IllegalAccessException {
throw new IllegalAccessException("Function is a utility class!!!");
}
}
I debugged the code and found out that the problem is this piece of code at org.springframework.data.util.TypeDiscoverer.class, this piece of code return (TypeInformation)((Optional)this.fieldTypes.computeIfAbsent(fieldname, this::getPropertyInformation)).orElse((Object)null); return Optional null, that is why it is not working, but I do not know how to fix this problem.
@Nullable
public TypeInformation<?> getProperty(String fieldname) {
int separatorIndex = fieldname.indexOf(46);
if (separatorIndex == -1) {
return (TypeInformation)((Optional)this.fieldTypes.computeIfAbsent(fieldname, this::getPropertyInformation)).orElse((Object)null);
} else {
String head = fieldname.substring(0, separatorIndex);
TypeInformation<?> info = this.getProperty(head);
return info == null ? null : info.getProperty(fieldname.substring(separatorIndex + 1));
}
}