Home > Software design >  Getting an ORA-00900 (Invalid SQL Statement) after moving @Transactionnal from Repository to service
Getting an ORA-00900 (Invalid SQL Statement) after moving @Transactionnal from Repository to service

Time:12-06

I am getting an java.sql.SQLSyntaxErrorException: ORA-00900: Invalid SQL Statement after moving the @Transactional and @Modifying annotations from the my repository methods to the service methods :

@Repository("someRepository")
public interface SomeRepository extends CrudRepository<SomeEntity, String>{
  //My code works if the next two line are uncommented !!
  //@Transactional
  //@Modifying
  @Query(nativeQuery = true, value = "delete from some_table where col = :param")
  int repoDelete(@Param("param") String param);
}

@Service(value = "someService")
  public class SomeServiceImpl implements SomeService {

  @Autowired SomeRepository repo;

  @Override
  @Transactional
  @Modifying
  public void serviceDelete(String id) throws UdhException {
    repo.repoDelete(id);
  }
}

CodePudding user response:

I have read some other questions and found the solution : the @Transactional annotation is not taken into account when it is applied to a method wich is called inside the bean.

For more details read the accepted response here (stack question)

  • Related