Java源码示例:org.springframework.data.jpa.repository.Modifying
示例1
@Transactional
@Modifying(clearAutomatically = true)
@Query("UPDATE org.apache.servicecomb.saga.alpha.core.Command c "
+ "SET c.status = :toStatus "
+ "WHERE c.globalTxId = :globalTxId "
+ " AND c.localTxId = :localTxId "
+ " AND c.status = :fromStatus")
void updateStatusByGlobalTxIdAndLocalTxId(
@Param("fromStatus") String fromStatus,
@Param("toStatus") String toStatus,
@Param("globalTxId") String globalTxId,
@Param("localTxId") String localTxId);
示例2
@Transactional
@Modifying
@Query("UPDATE TxEventAddition T SET T.compensateStatus = 1 WHERE T.instanceId = ?1 AND T.globalTxId = ?2 AND T.localTxId = ?3 AND T.compensateStatus = 0")
int updateCompensateStatus(String instanceId, String globalTxId, String localTxId);
示例3
@Transactional
@Modifying(clearAutomatically = true)
@Query("UPDATE org.apache.servicecomb.saga.alpha.core.TxTimeout t "
+ "SET t.status = :status "
+ "WHERE t.globalTxId = :globalTxId "
+ " AND t.localTxId = :localTxId")
void updateStatusByGlobalTxIdAndLocalTxId(
@Param("status") String status,
@Param("globalTxId") String globalTxId,
@Param("localTxId") String localTxId);
示例4
@Modifying
@Transactional
public void updateRoleMenu(int rid, Map<String, List<Integer>> menusIds) {
adminRoleMenuDAO.deleteAllByRid(rid);
List<AdminRoleMenu> rms = new ArrayList<>();
for (Integer mid : menusIds.get("menusIds")) {
AdminRoleMenu rm = new AdminRoleMenu();
rm.setMid(mid);
rm.setRid(rid);
rms.add(rm);
}
adminRoleMenuDAO.saveAll(rms);
}
示例5
@Modifying
@Query(
"update ModuleInfo set gmtModified = :#{#moduleInfo.gmtModified}" +
" where appName = :#{#moduleInfo.appName}" +
" and ip = :#{#moduleInfo.ip}"
)
int updateByAppNameAndIp(@Param("moduleInfo") ModuleInfo moduleInfo);
示例6
@Transactional
@Modifying
@Query(
value = "UPDATE RSS_FEED " +
"SET RSS_SITE = ?2 " +
"WHERE RSS_SITE = ?1 "
, nativeQuery = true)
public void updateByRssSite(String oriRssSite, String trgRssSite);
示例7
@Transactional
@Modifying(clearAutomatically = true)
@Query(value = "DELETE FROM txle_sample_merchant WHERE id = ?1", nativeQuery = true)
int deleteById(@Param("merchantid") long merchantid);
示例8
@Transactional
@Modifying
@Query(nativeQuery = true,value = "delete from t_sys_relation where roleid=?1")
int deleteByRoleId(Long roleId);
示例9
@Modifying
@Transactional
@Query(nativeQuery = true,value = "delete from t_sys_operation_log")
int clear();
示例10
@Transactional
@Modifying
@Query(value = "delete from #{#entityName} where block_height >= ?1 and block_height< ?2", nativeQuery = true)
public void rollback(long startBlockHeight, long endBlockHeight);
示例11
@Transactional
@Modifying
@Query(value = "update t_rule_engine set status=2 , delete_at=:deleteAt where id =:id", nativeQuery = true)
void deleteRuleEngine(@Param("id") Integer id, @Param("deleteAt") Long deleteAt);
示例12
@Modifying
@Transactional
@Query(value = "update Student a set a.name = '龙淘宝' where a.id =:id")
void updataUserByGuid(@Param("id") long id);
示例13
@Modifying
@Transactional
@Query(value = "update Student a set a.name = :name where a.id =:id")
void updataStudentById(@Param("name") String name, @Param("id") long id);
示例14
@Modifying
@Query("update Advertise a set a.status = :status,a.updateTime=:updateTime where a.id in :ids")
int alterStatusBatch(@Param("status")AdvertiseControlStatus status,@Param("updateTime")Date updateTime,@Param("ids")Long[] ids) ;
示例15
@Transactional
@Modifying(clearAutomatically = true)
@Query("UPDATE TxTimeout t SET t.status = 'DONE' WHERE t.status != 'DONE' AND t.surrogateId IN ?1")
void updateStatusOfFinishedTx(List<Long> surrogateIdList);
示例16
@Modifying(clearAutomatically=true)
@Transactional
@Query("update User set active=:active where email=:email")
int setActive(@Param("active") Integer active, @Param("email") String email);
示例17
@Modifying(clearAutomatically=true)
@Transactional
@Query("update User set outDate=:outDate, validataCode=:validataCode where email=:email")
int setOutDateAndValidataCode(@Param("outDate") String outDate, @Param("validataCode") String validataCode, @Param("email") String email);
示例18
@Modifying(clearAutomatically=true)
@Transactional
@Query("update User set active=:active where email=:email")
int setActive(@Param("active") Integer active, @Param("email") String email);
示例19
/**
* 获取随机六条文章作为推荐数据
*/
@Modifying
@Query(value = "SELECT * FROM ar_article ORDER BY rand() LIMIT 6",
nativeQuery = true)
List<Article> findRelatedByRand();
示例20
@Modifying
@Transactional
@Query(value = "update t_account set delete_at=:deleteAt where username=:username", nativeQuery = true)
void deleteByUserName(@Param("username") String username, @Param("deleteAt") Long deleteAt);
示例21
@Modifying
@Query("update ExchangeOrder exchange set exchange.tradedAmount = exchange.tradedAmount + ?1 where exchange.orderId = ?2")
int increaseTradeAmount(BigDecimal amount, String orderId);
示例22
@Modifying
@Query("delete from Category where id in (:ids)")
void deleteBatch(@Param("ids") List<String> ids);
示例23
@Modifying
@Query("update Order a set a.status=:status where a.status=2 and a.orderSn=:orderSn")
int updateAppealOrder( @Param("status") OrderStatus status, @Param("orderSn") String orderSn);
示例24
@Modifying
@Transactional
@Query(nativeQuery = true,value = "delete from t_sys_login_log")
int clear();
示例25
@Modifying
@Query(value = "update Member set signInAbility = true ")
void resetSignIn();
示例26
@Modifying
@Query("delete from Dict where id in (:ids)")
void deleteBatch(@Param("ids") List<String> ids);
示例27
@Modifying
@Query("delete from Resource where id in (:ids)")
void deleteBatch(@Param("ids") List<String> ids);
示例28
@Modifying
@Query("delete from Role where id in (:ids)")
void deleteBatch(List<String> ids);
示例29
@Modifying
@Query("update ExchangeOrder exchange set exchange.tradedAmount = exchange.tradedAmount + ?1 where exchange.orderId = ?2")
int increaseTradeAmount(BigDecimal amount, String orderId);
示例30
@Modifying
@Query("update Advertise a set a.status=1,a.remainAmount=0,a.number=0 where a.remainAmount=:amount and a.id=:id and a.status=0")
int putOffAdvertise( @Param("id") Long id, @Param("amount") BigDecimal amount);