首页 > 其他分享 >mybatis中往xml传递对象时

mybatis中往xml传递对象时

时间:2022-12-05 20:02:19浏览次数:41  
标签:xml orderPo 中往 price private status mybatis import id

实体类

package com.woniu.dao.po;

import java.math.BigDecimal;
import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * <p>
 * 
 * </p>
 *
 * @author naruto
 * @since 2022-12-05
 */
@Data
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor
public class OrderPo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 订单价格
     */
    private BigDecimal price;

    /**
     * 下单用户id
     */
    private Long userId;

    /**
     * 订单状态
     */
    private String status;


}

dao层

public interface OrderMapper {
    int saveOrder(@Param("orderPo") OrderPo orderPo);
    int saveOrder1(OrderPo orderPo);

}

maper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.woniu.dao.mapper.OrderMapper">
    <insert id="saveOrder" >
        insert into t_order (price,status,user_id) values (#{orderPo.price},#{orderPo.status},#{orderPo.userId})
    </insert>
    <insert id="saveOrder1" >
        insert into t_order (price,status,user_id) values (#{price},#{status},#{userId})
    </insert>
  
</mapper>

 

标签:xml,orderPo,中往,price,private,status,mybatis,import,id
From: https://www.cnblogs.com/Knightl8/p/16953314.html

相关文章