Reputation: 307
I'm getting following exception while starting my service
... org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'levelDetailsService': Unsatisfied dependency expressed through field 'storeRepo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'storeRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.tcs.opt.promotion.masterservice.dao.repo.StoreRepo.getStoreList(java.lang.Integer,java.util.List,java.lang.Character)! ...
This is my method call for repository in service layer
List<Object[]> storeObjs=storeRepo.getStoreList(salesOrgId,storeRequestDTO.getClassId(),'Y');
Here salesOrgId is Integer, storeRequestDTO.getClassId() is List of Integer
Repo class
@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 Class
@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
*/
}
}
Please help me to resolve this issue,
Upvotes: 0
Views: 6521
Reputation: 7335
I'd say this error means that the @Query syntax is incorrect. Further details probably appear further down the stacktrace, but it looks to me like you have probably mixed up column names and property names in your query.
You should be using the property names as Java knows them, rather than the column name in your query.
So, storeId
rather than store_id
. etc
Upvotes: 1