-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20 #1567
Comments
实体属性必须与数据库表字段一致,不能比数据库表字段多一些属性。 |
Your query returns 20 columns. Assuming I am right, it may be a kind of misconfiguration, but the error message should be improved. |
I did not use @AutomapConstructor,my code is as follows: @Data
@Builder
@ApiModel(description = "账号")
public class Account implements Serializable {
private static final long serialVersionUID = CocCoreVersion.SERIAL_VERSION_UID;
private Long id;
private String name;
private String nickname;
private String phoneNumber;
private Boolean phoneVerified;
private Integer sex;
private Date createdAt;
private Date updatedAt;
private Date lastLoginAt;
private String password;
private Integer passwordStrength;
private String headImgUrl;
private String address;
private Integer status;
private List<String> customerIds;
@ApiModelProperty(notes = "加密算法")
@JsonIgnore
private String encryptionAlgorithm;
private String email;
private Boolean emailVerified;
private String salt;
/**
* 职位
*/
private String position;
/**
* 员工号
*/
private String empno;
public AccountChangeMq toAccountChangeMq() {
AccountChangeMq accountChangeMq = new AccountChangeMq();
accountChangeMq.setAccountId(this.id);
accountChangeMq.setCreatedAt(this.createdAt);
return accountChangeMq;
}
public AccountDto toAccountDto() {
AccountDto accountDto = AccountDto
.builder()
.address(this.address)
.email(this.email)
.createdAt(this.createdAt)
.updatedAt(this.updatedAt)
.customerIds(this.customerIds)
.emailVerified(this.emailVerified)
.empno(this.empno)
.headImgUrl(this.headImgUrl)
//.isPrimary(this.isPrimary)
.lastLoginAt(this.lastLoginAt)
.phoneNumber(this.phoneNumber)
.phoneVerified(this.phoneVerified)
.nickname(this.nickname)
.name(this.name)
.id(this.id)
.build();
return accountDto;
}
} mapper: <resultMap id="AccountResultMap" type="com.jiankunking.test.account.model.po.Account">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="nickname" column="nickname"/>
<result property="phoneNumber" column="phone_number"/>
<result property="phoneVerified" column="phone_verified"/>
<result property="sex" column="sex"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
<result property="lastLoginAt" column="last_login_at"/>
<result property="password" column="password"/>
<result property="passwordStrength" column="password_strength"/>
<result property="headImgUrl" column="head_img_url"/>
<result property="address" column="address"/>
<result property="status" column="status"/>
<result property="encryptionAlgorithm" column="encryption_algorithm"/>
<result property="email" column="email"/>
<result property="emailVerified" column="email_verified"/>
<result property="salt" column="salt"/>
<result property="position" column="position"/>
<result property="empno" column="empno"/>
</resultMap>
<select id="selectByPrimaryKey" parameterType="_long" resultMap="AccountResultMap">
select
id, name, nickname, phone_number, phone_verified, sex, created_at, updated_at, last_login_at, password, password_strength, head_img_url, address, status, encryption_algorithm, email, email_verified, salt, position, empno
from accounts
where id = #{accountID,jdbcType=BIGINT}
</select> |
Thanks for the code, @jiankunking . To use the result map, MyBatis needs to instantiate the p.s. |
Thank you for your advice @harawata |
Thanks for the follow-up, @jiankunking ! |
The text was updated successfully, but these errors were encountered: