fixed: 使用QueryMethods.count()时出错 close #I6X2M6

This commit is contained in:
开源海哥 2023-04-19 17:05:53 +08:00
parent c149e9c7a7
commit d82536b5cd
4 changed files with 10 additions and 57 deletions

View File

@ -18,7 +18,7 @@ package com.mybatisflex.core.query;
public class QueryMethods {
public static FunctionQueryColumn count() {
return new FunctionQueryColumn("COUNT", "*");
return new FunctionQueryColumn("COUNT", new StringQueryColumn("*"));
}
public static FunctionQueryColumn count(String column) {

View File

@ -22,22 +22,12 @@ public class Account extends BaseAccount implements Serializable {
private int age;
private SexEnum sex;
private Date birthday;
@Column("DEPT_ID_")
private String deptId;
@Column(typeHandler = Fastjson2TypeHandler.class,isLarge = true)
private Map<String, Object> options;
private TypeEnum typeEnum;
// @Column(isLogicDelete = true)
// private boolean deleteFlag;
public Long getId() {
return id;
@ -63,14 +53,6 @@ public class Account extends BaseAccount implements Serializable {
this.age = age;
}
public SexEnum getSex() {
return sex;
}
public void setSex(SexEnum sex) {
this.sex = sex;
}
public Date getBirthday() {
return birthday;
}
@ -94,30 +76,6 @@ public class Account extends BaseAccount implements Serializable {
options.put(key, value);
}
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public TypeEnum getTypeEnum() {
return typeEnum;
}
public void setTypeEnum(TypeEnum typeEnum) {
this.typeEnum = typeEnum;
}
// public boolean isDeleteFlag() {
// return deleteFlag;
// }
//
// public void setDeleteFlag(boolean deleteFlag) {
// this.deleteFlag = deleteFlag;
// }
@Override
public String toString() {
@ -125,11 +83,8 @@ public class Account extends BaseAccount implements Serializable {
"id=" + id +
", userName='" + userName + '\'' +
", age=" + age +
", sex=" + sex +
", birthday=" + birthday +
", deptId='" + deptId + '\'' +
", options=" + options +
", typeEnum=" + typeEnum +
'}';
}
}

View File

@ -1,16 +1,5 @@
package com.mybatisflex.test;
import java.util.Date;
public class BaseAccount {
private Date createTime;
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -26,6 +26,11 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import javax.sql.DataSource;
import java.util.List;
import static com.mybatisflex.core.query.QueryMethods.count;
import static com.mybatisflex.test.table.Tables.ACCOUNT;
public class EntityTestStarter {
public static void main(String[] args) {
@ -50,6 +55,10 @@ public class EntityTestStarter {
AccountMapper accountMapper = bootstrap.getMapper(AccountMapper.class);
QueryWrapper wrapper = QueryWrapper.create().select(ACCOUNT.DEFAULT_COLUMNS).select(count()).from(ACCOUNT)
.groupBy(ACCOUNT.ID);
List<Account> accounts = accountMapper.selectListByQuery(wrapper);
Page<Account> paginate = accountMapper.paginate(new Page<>(1,10), new QueryWrapper());
System.out.println(paginate);