mybatis的xml配置文件中使用select语句数据不全

我的数据表里项很多,但是用mybaits中的xml配置文件select语句却只返回了几句话,之前我的代码是这样的:

<select id="selectAll" resultType="entity.Transaction">
  select
  *
  from transaction
select>

其中entity.Transaction指的是我建立好的实体类,里面有一个所有属性的构造函数,所以查找之后默认会调用该构造函数,构造函数如下,,,

public Transaction(Integer id, String time, String fromUserName, String fromUserType, String toUserName, String toUserType, Double transferValue, Double fromUserBalance, Double toUserBalance, String detail) {
    this.id = id;
    this.time = time;
    this.fromUserName = fromUserName;
    this.fromUserType = fromUserType;
    this.toUserName = toUserName;
    this.toUserType = toUserType;
    this.transferValue = transferValue;
    this.fromUserBalance = fromUserBalance;
    this.toUserBalance = toUserBalance;
    this.detail = detail;
}
但是调用该构造函数是不好用的,所以后来改成如下代码就好用了
<resultMap id="BaseResultMap" type="entity.Transaction">
  <constructor>
    <idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
    <arg column="time" javaType="java.lang.String" jdbcType="VARCHAR" />
    <arg column="from_user_name" javaType="java.lang.String" jdbcType="VARCHAR" />
    <arg column="from_user_type" javaType="java.lang.String" jdbcType="CHAR" />
    <arg column="to_user_name" javaType="java.lang.String" jdbcType="VARCHAR" />
    <arg column="to_user_type" javaType="java.lang.String" jdbcType="CHAR" />
    <arg column="transfer_value" javaType="java.lang.Double" jdbcType="DOUBLE" />
    <arg column="from_user_balance" javaType="java.lang.Double" jdbcType="DOUBLE" />
    <arg column="to_user_balance" javaType="java.lang.Double" jdbcType="DOUBLE" />
    <arg column="detail" javaType="java.lang.String" jdbcType="VARCHAR" />
  constructor>
resultMap>

<sql id="Base_Column_List">
  id, time, from_user_name, from_user_type, to_user_name, to_user_type, transfer_value, 
  from_user_balance, to_user_balance, detail
sql>

<select id="selectAll" resultMap="BaseResultMap">
  select
  <include refid="Base_Column_List" />
  from transaction
select>

也就是返回值的构造放在了xml文件里

你可能感兴趣的:(javaweb)