i'm trying to update "PA49_Debut"column with : - the"PA49_Debut" value from the second table if the product exists there - else "PA49_Debut" from the same table if the product exists in the previous rows - else "PA49_Actuel" from the same table take a look to the code in the repository
public interface FSrepository extends JpaRepository<FSmodel, String> {
@Transactional
@Modifying
@Query("Update FSmodel FS Set FS.PA49_Debut = CASE WHEN EXISTES (SELECT 1 FROM ISmodel SI where FS.Partnumber=SI.Partnumber)" +
" THEN SI.PA49 " +
"WHEN EXISTS (SELECT 1 FROM FSmodel FS2 WHERE FS.Partnumber=FS2.Partnumber AND FS.id>FS2.id )" +
" THEN FS2.PA49_Debut "+
" ELSE (FS.PA49_Actuel) "
+ "END" )
void setPA49Debut(); ```
these are my ISmodel and FSmodel entities
@Entity
public class FSmodel {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long id;
public String Partnumber;
public String Materialgroup;
public String Warehouse;
public Float Value;
public Float Stock;
public Float PA49_Actuel;
public Float PA49_Debut;
public String article_fg;
public Float Priceperunit;}
@Entity
public class ISmodel {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long id;
public String Partnumber;
public String Materialgroup;
public String Warehouse;
public Float Stock;
public Float Value;
public Float PA49;
public Float STPA49; }
and that is the error
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller': Unsatisfied dependency expressed through field 'FSrepos'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FSrepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract void com.example.demo2.repository.FSrepository.setPA49Debut()!
Caused by: java.lang.NullPointerException: null
Any help would be greatly appreciated. Thanks.