не в состоянии выполнить между датой данных jpa с аннотацией запроса - PullRequest
0 голосов
/ 12 сентября 2018

Я использую аннотацию org.springframework.data.jpa.repository.Query для заполнения результирующего набора с использованием данных Spring jpa. У меня есть billing history таблица с колонкой creationdate. Я хочу использовать sql date between запрос с использованием @Query аннотации. Ниже мой код:

@Query( "SELECT billhistory FROM BillingHistory billhistory INNER JOIN billhistory.userInfo user WHERE user.userName = :username AND billhistory.creationdate between :from and :to" )
List<BillingHistory> getBillingHistoryByUserNameAndDate( @Param("username") String username, @Param("from")Date from, @Param("to") Date to );

здесь я также попробовал String тип данных для параметров from и to. но в моем приложении SpringBoot появляется ошибка:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'billingHistoryController' defined in file [D:\newWorkSpace\JasperReport_project\target\classes\com\google\jasper\controller\BillingHistoryController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'billingHistoryServiceImpl' defined in file [D:\newWorkSpace\JasperReport_project\target\classes\com\google\jasper\service\BillingHistoryServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'billingHistoryRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.google.jasper.repository.BillingHistoryRepository.getBillingHistoryByUserNameAndDate(java.lang.String,java.lang.String,java.lang.String)!

***** ****** EDIT 1017 *

BillingHistory entity

package com.google.jasper.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonFormat;

@Entity
@Table( name = "billing_history", catalog = "radius" )
public class BillingHistory implements Serializable{

    private static final long serialVersionUID = 8329286536383150966L;

    @Id
    @GeneratedValue( strategy = GenerationType.AUTO )
    @Column( name = "id", nullable = false, updatable = false )
    private Integer id;

    @ManyToOne()
    @JoinColumn( name = "username" )
    private UserInfo userInfo;

    @ManyToOne
    @JoinColumn( name = "planId" )
    private BillingPlans billingPlans;

    @Column( name = "billAmount" )
    private String billAmount;

    @Column( name = "billAction" )
    private String billAction;

    @Column( name = "billPerformer" )
    private String billPerformer;

    @Column( name = "billReason" )
    private String billReason;

    @Column( name = "paymentMethod" )
    private String paymentMethod;

    @Column( name = "cash" )
    private String cash;

    @Column( name = "creditcardname" )
    private String creditcardName;

    @Column( name = "creditcardnumber" )
    private String creditcardNumber;

    @Column( name = "creditcardtype" )
    private String creditcardType;

    @Column( name = "creditcardexp" )
    private String creditcardExp;

    @Column( name = "coupon" )
    private String coupon;

    @Column( name = "discount" )
    private String discount;

    @Column( name = "notes" )
    private String notes;

    @JsonFormat( pattern = "dd-MM-yyyy hh:mm:ss" )
    @Column( name = "creationdate" )
    private Date creationDate;

    @Column( name = "creationby" )
    private String creationBy;

    @JsonFormat( pattern = "dd-MM-yyyy hh:mm:ss" )
    @Column( name = "updatedate" )
    private Date updateDate;

    @Column( name = "updateby" )
    private String updateBy;

    public BillingHistory() {

    }

    public BillingHistory(Integer id, UserInfo userInfo, BillingPlans billingPlans, String billAmount,
            String billAction, String billPerformer, String billReason, String paymentMethod, String cash,
            String creditcardName, String creditcardNumber, String creditcardType, String creditcardExp, String coupon,
            String discount, String notes, Date creationDate, String creationBy, Date updateDate, String updateBy) {
        super();
        this.id = id;
        this.userInfo = userInfo;
        this.billingPlans = billingPlans;
        this.billAmount = billAmount;
        this.billAction = billAction;
        this.billPerformer = billPerformer;
        this.billReason = billReason;
        this.paymentMethod = paymentMethod;
        this.cash = cash;
        this.creditcardName = creditcardName;
        this.creditcardNumber = creditcardNumber;
        this.creditcardType = creditcardType;
        this.creditcardExp = creditcardExp;
        this.coupon = coupon;
        this.discount = discount;
        this.notes = notes;
        this.creationDate = creationDate;
        this.creationBy = creationBy;
        this.updateDate = updateDate;
        this.updateBy = updateBy;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public UserInfo getUserInfo() {
        return userInfo;
    }

    public void setUserInfo(UserInfo userInfo) {
        this.userInfo = userInfo;
    }

    public BillingPlans getBillingPlans() {
        return billingPlans;
    }

    public void setBillingPlans(BillingPlans billingPlans) {
        this.billingPlans = billingPlans;
    }

    public String getBillAmount() {
        return billAmount;
    }

    public void setBillAmount(String billAmount) {
        this.billAmount = billAmount;
    }

    public String getBillAction() {
        return billAction;
    }

    public void setBillAction(String billAction) {
        this.billAction = billAction;
    }

    public String getBillPerformer() {
        return billPerformer;
    }

    public void setBillPerformer(String billPerformer) {
        this.billPerformer = billPerformer;
    }

    public String getBillReason() {
        return billReason;
    }

    public void setBillReason(String billReason) {
        this.billReason = billReason;
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public String getCash() {
        return cash;
    }

    public void setCash(String cash) {
        this.cash = cash;
    }

    public String getCreditcardName() {
        return creditcardName;
    }

    public void setCreditcardName(String creditcardName) {
        this.creditcardName = creditcardName;
    }

    public String getCreditcardNumber() {
        return creditcardNumber;
    }

    public void setCreditcardNumber(String creditcardNumber) {
        this.creditcardNumber = creditcardNumber;
    }

    public String getCreditcardType() {
        return creditcardType;
    }

    public void setCreditcardType(String creditcardType) {
        this.creditcardType = creditcardType;
    }

    public String getCreditcardExp() {
        return creditcardExp;
    }

    public void setCreditcardExp(String creditcardExp) {
        this.creditcardExp = creditcardExp;
    }

    public String getCoupon() {
        return coupon;
    }

    public void setCoupon(String coupon) {
        this.coupon = coupon;
    }

    public String getDiscount() {
        return discount;
    }

    public void setDiscount(String discount) {
        this.discount = discount;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public String getCreationBy() {
        return creationBy;
    }

    public void setCreationBy(String creationBy) {
        this.creationBy = creationBy;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    @Override
    public String toString() {
        return "BillingHistory [id=" + id + ", userInfo=" + userInfo + ", billingPlans=" + billingPlans
                + ", billAmount=" + billAmount + ", billAction=" + billAction + ", billPerformer=" + billPerformer
                + ", billReason=" + billReason + ", paymentMethod=" + paymentMethod + ", cash=" + cash
                + ", creditcardName=" + creditcardName + ", creditcardNumber=" + creditcardNumber + ", creditcardType="
                + creditcardType + ", creditcardExp=" + creditcardExp + ", coupon=" + coupon + ", discount=" + discount
                + ", notes=" + notes + ", creationDate=" + creationDate + ", creationBy=" + creationBy + ", updateDate="
                + updateDate + ", updateBy=" + updateBy + "]";
    }



}

где я ошибаюсь в этом запросе .. нужен совет.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...