Java Code Examples for com.baomidou.mybatisplus.core.mapper.BaseMapper#selectCount()

The following examples show how to use com.baomidou.mybatisplus.core.mapper.BaseMapper#selectCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Override
public <K extends Comparable, T extends IdentityObject<K>> long countInstances(Class<T> clazz) {
	MyBatisMetadata metadata = metadatas.get(clazz);
	BaseMapper mapper = template.getMapper(metadata.getMapperClass());
	QueryWrapper<?> query = new QueryWrapper<>();
	return mapper.selectCount(query);
}
 
Example 2
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Override
public <K extends Comparable, T extends IdentityObject<K>> long countIntersection(Class<T> clazz, Map<String, Object> condition) {
	MyBatisMetadata metadata = metadatas.get(clazz);
	BaseMapper mapper = template.getMapper(metadata.getMapperClass());
	QueryWrapper<?> query = new QueryWrapper<>();
	for (Entry<String, Object> term : condition.entrySet()) {
		query.and((wrapper) -> {
			return wrapper.eq(metadata.getColumnName(term.getKey()), term.getValue());
		});
	}
	return mapper.selectCount(query);
}
 
Example 3
Source File: MyBatisAccessor.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
@Override
public <K extends Comparable, T extends IdentityObject<K>> long countUnion(Class<T> clazz, Map<String, Object> condition) {
	MyBatisMetadata metadata = metadatas.get(clazz);
	BaseMapper mapper = template.getMapper(metadata.getMapperClass());
	QueryWrapper<?> query = new QueryWrapper<>();
	for (Entry<String, Object> term : condition.entrySet()) {
		query.or((wrapper) -> {
			return wrapper.eq(metadata.getColumnName(term.getKey()), term.getValue());
		});
	}
	return mapper.selectCount(query);
}