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 com.simple.orm.dao.BaseDaoAdapter;
import com.simple.orm.domain.Page;
import com.simple.orm.domain.PageImpl;
import com.simple.orm.domain.Pageable;
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());
Long 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());
Long total=count(property,value);
return new PageImpl(contents, pageable, total);
}
public Page query(Pageable pageable) throws SQLException {
List contents=query();
Long total=count();
return new PageImpl(contents, pageable, total);
}
public M save(M m) throws SQLException {
String pk=super.getPkPropertyName();
if(getValueByProperty(m,pk)!=null){
return update(m);
}
return insert(m);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy