com.simple.orm.service.impl.BaseServiceImpl Maven / Gradle / Ivy
package com.simple.orm.service.impl;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import com.simple.orm.dao.BaseDaoAdapter;
import com.simple.orm.service.BaseService;
public abstract class BaseServiceImpl extends BaseDaoAdapter implements BaseService{
public Page query(M m, Pageable pageable) throws SQLException {
List contents=query(m, pageable.getOffset(), pageable.getPageSize());
int total=count(m);
return new PageImpl(contents, pageable, total);
}
public Page query(String property, Object value, Pageable pageable) throws SQLException {
List contents=query(property, value, pageable.getOffset(), pageable.getPageSize());
int total=count(property,value);
return new PageImpl(contents, pageable, total);
}
public Page query(Pageable pageable) throws SQLException {
List contents=query();
int total=count();
return new PageImpl(contents, pageable, total);
}
public M save(M m) throws SQLException {
if(getValueByProperty(m, getPrimaryProperty())!=null){
return update(m);
}
return insert(m);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy