当前位置: 首页 > 知识库问答 >
问题:

我发现调用init方法失败;嵌套异常是存储库类方法调用上的java.lang.IllegalArgumentException

东方吕恭
2023-03-14

我在启动服务时遇到以下异常

...org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“level detailsservice”的bean时出错:通过字段“store repo”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“Store repo”的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:方法public abstract java.util.list com.tcs.opt.promotion.masterservice.dao.repo.StorerePo.GetStoreList(java.lang.integer,java.util.list,java.lang.character)查询验证失败!...

这是我对服务层存储库的方法调用

List<Object[]> storeObjs=storeRepo.getStoreList(salesOrgId,storeRequestDTO.getClassId(),'Y');

这里,salesOrgId是整数,StoreRequestDto.getClassid()是整数列表

回购类

@Repository
public interface StoreRepo extends JpaRepository<StoreEntity, Integer> {
    

    @Query("select str.store_id,str.store_number,str.store_name,str.city,str.state from StoreEntity str left outer join master.promo_market_store pstr "
            + "on str.store_id=pstr.store_id where str.salesOrgID=:salesOrgID and pstr.level_id in (:levelIdList) and str.activeF=:activeF")
    List<Object[]> getStoreList(@Param("salesOrgID") Integer salesOrgID,@Param("levelIdList") List<Integer> levelIdList,@Param("activeF") Character activeF);

}

实体类

@Entity
@Table(name=MasterQueryConstants.STORE_TBL,schema=MasterQueryConstants.MASTER_SCHEMA)
public class StoreEntity implements Serializable{
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name="store_id")
    private Integer storeId;
    @Column(name="sales_org_id")
    private Integer salesOrgID;
    @Column(name="store_number")
    private Integer storeNumber;
    @Column(name="store_name")
    private String storeName;
    @Column(name="store_description")
    private String storeDescription;
    @Column(name="active_f")
    private Character activeF;
    @Column(name="city")
    private String city;
    @Column(name="state")
    private String state;
    
    
    public Integer getStoreId() {
        return storeId;
    }
    public void setStoreId(Integer storeId) {
        this.storeId = storeId;
    }
    public Integer getSalesOrgID() {
        return salesOrgID;
    }
    public void setSalesOrgID(Integer salesOrgID) {
        this.salesOrgID = salesOrgID;
    }
    public Integer getStoreNumber() {
        return storeNumber;
    }
    public void setStoreNumber(Integer storeNumber) {
        this.storeNumber = storeNumber;
    }
    public String getStoreName() {
        return storeName;
    }
    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }
    public String getStoreDescription() {
        return storeDescription;
    }
    public void setStoreDescription(String storeDescription) {
        this.storeDescription = storeDescription;
    }
    public Character getActiveF() {
        return activeF;
    }
    public void setActiveF(Character activeF) {
        this.activeF = activeF;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    
    public StoreEntity()
    {
        /**
         * Default Constructor
         */
    }
}

请帮我解决这个问题,

共有1个答案

纪实
2023-03-14

我认为这个错误意味着@query语法不正确。更多的细节可能会出现在stacktrace的下面,但在我看来,您可能在查询中混淆了列名和属性名。

您应该使用Java知道的属性名称,而不是查询中的列名。

因此,storeid而不是store_id。ETC

 类似资料: