spring-projects/spring-data-examples

@Query support any parser, for example.

fengsoshuai opened this issue · 4 comments

    @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.

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);

the package is org.springframework.data.r2dbc.repository.Query

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}.

Thanks!