ক্যোয়ারি মুছে ফেলার জন্য - ব্যবহার করুন @Modifying
এবং পছন্দ মতো এর @Transactional
আগে @Query
: -
@Repository
public interface CopyRepository extends JpaRepository<Copy, Integer> {
@Modifying
@Transactional
@Query(value = "DELETE FROM tbl_copy where trade_id = ?1 ; ", nativeQuery = true)
void deleteCopyByTradeId(Integer id);
}
এটি java.sql.SQLException: Can not issue data manipulation statements with executeQuery()
ত্রুটি দেয় না।
সম্পাদনা করুন:
যেহেতু এই উত্তরটি অনেকগুলি উপার্জন পাচ্ছে, তাই আরও বোঝার জন্য আমি আপনাকে ডকুমেন্টেশনগুলিতে উল্লেখ করব।
@ লেনদেন
By default, CRUD methods on repository instances are transactional. For read operations,
the transaction configuration readOnly flag is set to true.
All others are configured with a plain @Transactional so that default transaction
configuration applies.
@ মডিডিং
Indicates a query method should be considered as modifying query as that changes the way
it needs to be executed. This annotation is only considered if used on query methods defined
through a Query annotation). It
derived from the method name as they already have control over the underlying data access
APIs or specify if they are modifying by their name.
Queries that require a @Modifying annotation include INSERT, UPDATE, DELETE, and DDL
statements.