mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed: 使用QueryMethods.count()时出错 close #I6X2M6
This commit is contained in:
parent
c149e9c7a7
commit
d82536b5cd
@ -18,7 +18,7 @@ package com.mybatisflex.core.query;
|
|||||||
public class QueryMethods {
|
public class QueryMethods {
|
||||||
|
|
||||||
public static FunctionQueryColumn count() {
|
public static FunctionQueryColumn count() {
|
||||||
return new FunctionQueryColumn("COUNT", "*");
|
return new FunctionQueryColumn("COUNT", new StringQueryColumn("*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FunctionQueryColumn count(String column) {
|
public static FunctionQueryColumn count(String column) {
|
||||||
|
|||||||
@ -22,22 +22,12 @@ public class Account extends BaseAccount implements Serializable {
|
|||||||
|
|
||||||
private int age;
|
private int age;
|
||||||
|
|
||||||
private SexEnum sex;
|
|
||||||
|
|
||||||
private Date birthday;
|
private Date birthday;
|
||||||
|
|
||||||
@Column("DEPT_ID_")
|
|
||||||
private String deptId;
|
|
||||||
|
|
||||||
@Column(typeHandler = Fastjson2TypeHandler.class,isLarge = true)
|
@Column(typeHandler = Fastjson2TypeHandler.class,isLarge = true)
|
||||||
private Map<String, Object> options;
|
private Map<String, Object> options;
|
||||||
|
|
||||||
|
|
||||||
private TypeEnum typeEnum;
|
|
||||||
|
|
||||||
// @Column(isLogicDelete = true)
|
|
||||||
// private boolean deleteFlag;
|
|
||||||
|
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -63,14 +53,6 @@ public class Account extends BaseAccount implements Serializable {
|
|||||||
this.age = age;
|
this.age = age;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SexEnum getSex() {
|
|
||||||
return sex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSex(SexEnum sex) {
|
|
||||||
this.sex = sex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getBirthday() {
|
public Date getBirthday() {
|
||||||
return birthday;
|
return birthday;
|
||||||
}
|
}
|
||||||
@ -94,30 +76,6 @@ public class Account extends BaseAccount implements Serializable {
|
|||||||
options.put(key, value);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@ -125,11 +83,8 @@ public class Account extends BaseAccount implements Serializable {
|
|||||||
"id=" + id +
|
"id=" + id +
|
||||||
", userName='" + userName + '\'' +
|
", userName='" + userName + '\'' +
|
||||||
", age=" + age +
|
", age=" + age +
|
||||||
", sex=" + sex +
|
|
||||||
", birthday=" + birthday +
|
", birthday=" + birthday +
|
||||||
", deptId='" + deptId + '\'' +
|
|
||||||
", options=" + options +
|
", options=" + options +
|
||||||
", typeEnum=" + typeEnum +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,5 @@
|
|||||||
package com.mybatisflex.test;
|
package com.mybatisflex.test;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class BaseAccount {
|
public class BaseAccount {
|
||||||
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
public Date getCreateTime() {
|
|
||||||
return createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateTime(Date createTime) {
|
|
||||||
this.createTime = createTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,11 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
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 class EntityTestStarter {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -50,6 +55,10 @@ public class EntityTestStarter {
|
|||||||
|
|
||||||
AccountMapper accountMapper = bootstrap.getMapper(AccountMapper.class);
|
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());
|
Page<Account> paginate = accountMapper.paginate(new Page<>(1,10), new QueryWrapper());
|
||||||
System.out.println(paginate);
|
System.out.println(paginate);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user