2017-09-20 2 views
0

나는이 오류가 타입 missmatch 예외라고 생각하지만, 나는 왜 그것을 얻고 있는지 모른다.스프링 데이터 업데이트 쿼리 오류

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'carController' defined in file [C:\Users\aleks\Desktop\Spring Boot With Rest\app\target\classes\carMarket\app\controllers\CarController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'carServiceImpl' defined in file [C:\Users\aleks\Desktop\Spring Boot With Rest\app\target\classes\carMarket\app\services\implementations\CarServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'carRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract carMarket.app.orm.Car carMarket.app.repositories.CarRepository.updateCar(java.lang.String,java.lang.String,java.lang.Long,java.math.BigDecimal)! 

이 내가

@Transactional 
@Override 
public boolean editCar(long userId, long carId, CarBindingModel carBindingModel) 
{ 
    Car car = this.carRepository.findById(carId); 
    Car map = this.modelMapper.map(carBindingModel, Car.class); 
    String make = carBindingModel.getMake(); 
    String model = carBindingModel.getModel(); 
    Long milesDriven = carBindingModel.getMilesDriven(); 
    BigDecimal price = carBindingModel.getPrice(); 
    Car car1 = this.carRepository.updateCar(make, model, milesDriven, price); 
    return false; 
} 

으로 호출하고 서비스 그리고 이것은 공공 getter 및 setter 및 공공 빈 생성자가 물론 ORM

@Entity(name = "cars") 
public class Car 
{ 
    @Id 
    @GeneratedValue(strategy = GenerationType.IDENTITY) 
    private Long id; 
    @NotNull 
    private String make; 
    @NotNull 
    private String model; 
    @NotNull 
    private BigDecimal price; 
    @NotNull 
    private Long milesDriven; 
    @JoinColumn(name = "user_id", referencedColumnName = "id") 
    @OneToOne(fetch = FetchType.EAGER) 
    private User user; 

입니다. 이 오류는 업데이트 방법에 accures , 내가

@Modifying 
@Query(value = "UPDATE Car as s set s.make= :make, s.model= :model, s.milesDriven= :milesDriven, s.price= :price") 
Car updateCar(@Param(value = "make") String make, @Param(value = "model") String model, @Param(value = "milesDriven") Long milesDriven, @Param(value = "price") BigDecimal price); 

이 Btw는이 컴파일시 오류가있는 쿼리 그것이 자기에게 있습니다 .. 삭제에 문제가 있거나 방법을 찾을 수 없습니다.

+0

add updateCar 메서드 –

답변

0

그래서 내 문제는 fallowing 내가 그래서 UPDATE Car을하지 않았을해야이

@Query(value = "UPDATE Car as s set s.make= :make, s.model= :model, s.milesDriven= :milesDriven, s.price= :price") 

했다 저장소 방법 위의 JPQL이

@Entity(name = "cars") 
public class Car 

그리고 있었다 하지만 UPDATE cars했다