Reputation: 316
I have an custom query for delete records from 2 tables as follows
@Repository
public interface RoamingStatusHistoryRepository extends JpaRepository<RoamingStatusHistory, String> {
@Query("DELETE rsh,rs from RoamingStatusHistory rsh inner join RoamingStatus rs on rsh.msisdn = rs.msisdn where TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'")
public List<Date> deleteByDate();
}
But after DELETE IntelliJ saying from expected got rsh and after rsh there is a error saying alias definition or WHERE expected, got ','
How to fix this issue. Have researched in the internet but couldn't find a solution
Upvotes: 1
Views: 5989
Reputation: 36173
I assume that this query is a native SQL query so you have to add nativeQuery = true
@Repository
public interface RoamingStatusHistoryRepository extends JpaRepository<RoamingStatusHistory, String> {
@Query("DELETE rsh,rs from RoamingStatusHistory rsh inner join RoamingStatus rs on rsh.msisdn = rs.msisdn where TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'",
nativeQuery = true)
public List<Date> deleteByDate();
}
Upvotes: 2