@Query support any parser, for example.
fengsoshuai opened this issue · 4 comments
fengsoshuai commented
@Query("insert into stock_logistics_no (logistics_id, logistics_type, logistics_no, stockout_id, send_province, send_city, send_district, send_address, status, created)" +
" value (:logisticsId, :logisticsType, :logisticsNo, :stockOutId, :sendProvince," +
":sendCity, :sendDistrict, :sendAddress, :status, :created) ON DUPLICATE KEY UPDATE stockout_id=VALUES(stockout_id),status=VALUES(status)")
Mono<Void> insertIntoOnDuplicateKey(Integer logisticsId, Integer logisticsType, String logisticsNo, Integer stockOutId,
String sendProvince, String sendCity, String sendDistrict, String sendAddress, Integer status, LocalDateTime created);
default Mono<Void> insertIntoOnDuplicateKey(StockLogisticsNo stockLogisticsNo) {
return insertIntoOnDuplicateKey(
stockLogisticsNo.getLogisticsId(), stockLogisticsNo.getLogisticsType(), stockLogisticsNo.getLogisticsNo(),
stockLogisticsNo.getStockOutId(), stockLogisticsNo.getSendProvince(),
stockLogisticsNo.getSendCity(), stockLogisticsNo.getSendDistrict(), stockLogisticsNo.getSendAddress(),
stockLogisticsNo.getStatus(), LocalDateTime.now());
}
I need use an Object to repalce this default method.
fengsoshuai commented
for examlple:
@Query("insert into stock_logistics_no (logistics_id, logistics_type, logistics_no, stockout_id, send_province, send_city, send_district, send_address, status, created)" +
" value (:stockLogisticsNo.logisticsId, :stockLogisticsNo.logisticsType, :stockLogisticsNo.logisticsNo, :stockLogisticsNo.stockOutId, :stockLogisticsNo.sendProvince," +
":stockLogisticsNo.sendCity, :stockLogisticsNo.sendDistrict, :stockLogisticsNo.sendAddress, :stockLogisticsNo.status, :stockLogisticsNo.created) ON DUPLICATE KEY UPDATE stockout_id=VALUES(stockout_id),status=VALUES(status)")
Mono<Void> insertIntoOnDuplicateKeyExample(StockLogisticsNo stockLogisticsNo);
fengsoshuai commented
the package is org.springframework.data.r2dbc.repository.Query
mp911de commented
Thanks for submitting an issue. This repository hosts only Spring Data examples and is not a general Q&A forum. Please take a look at the SpEL syntax that allows you to include dynamic parameter markers such as #{stockLogisticsNo.logisticsId}
.
fengsoshuai commented
Thanks!