0

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));
    }
}
  • where is that `TypeDiscoverer` code from ? spring-data-commons-2.1.3.RELEASE.jar doesn't have that.`@Nullable public TypeInformation> getProperty(String fieldname) { int separatorIndex = fieldname.indexOf('.'); if (separatorIndex == -1) { return fieldTypes.computeIfAbsent(fieldname, this::getPropertyInformation).orElse(null); } String head = fieldname.substring(0, separatorIndex); TypeInformation> info = getProperty(head); if (info == null) { return null; } return info.getProperty(fieldname.substring(separatorIndex + 1)); }` – user3487063 Nov 19 '19 at 16:27
  • @user3487063 spring-data-commons-2.1.5.RELEASE.jar has it. – Ferid Qelenderli Nov 19 '19 at 16:36
  • 2.1.5.RELEASE has this: `@Nullable public TypeInformation> getProperty(String fieldname) { int separatorIndex = fieldname.indexOf('.'); if (separatorIndex == -1) { return fieldTypes.computeIfAbsent(fieldname, this::getPropertyInformation).orElse(null); } String head = fieldname.substring(0, separatorIndex); TypeInformation> info = getProperty(head); if (info == null) { return null; } return info.getProperty(fieldname.substring(separatorIndex + 1)); }` – user3487063 Nov 19 '19 at 16:39
  • do you see 46 in code ? this line : `fieldname.indexOf(46);` thats ascii for '.' though – user3487063 Nov 19 '19 at 16:39
  • @user3487063 after downloading source it is like you said, I just haven't downloaded the source code – Ferid Qelenderli Nov 19 '19 at 16:42

0 Answers0