将 @Transactionnal 从存储库移动到服务后出现 ORA-00900(无效 SQL 语句)
Getting an ORA-00900 (Invalid SQL Statement) after moving @Transactionnal from Repository to service
将 @Transactional
和 @Modifying
注释从我的存储库方法移动到服务方法后,我得到一个 java.sql.SQLSyntaxErrorException: ORA-00900: Invalid SQL Statement
:
@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);
}
}
我阅读了其他一些问题并找到了解决方案:@Transactional 注释在应用于在 bean 内部调用的方法时未被考虑在内。
有关详细信息,请阅读已接受的回复 here(堆栈问题)
将 @Transactional
和 @Modifying
注释从我的存储库方法移动到服务方法后,我得到一个 java.sql.SQLSyntaxErrorException: ORA-00900: Invalid SQL Statement
:
@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);
}
}
我阅读了其他一些问题并找到了解决方案:@Transactional 注释在应用于在 bean 内部调用的方法时未被考虑在内。
有关详细信息,请阅读已接受的回复 here(堆栈问题)