.....
public static class MetaPath extends EntityPathSupport<App> {
public FieldPath<Integer, App> id = createFieldPath(Integer.class,"id",JdbcType.INTEGER);;
public FieldPath<String, App> appName = createFieldPath(String.class,"app_name",JdbcType.VARCHAR);;
public FieldPath<Byte, App> platformType = createFieldPath(Byte.class,"platform_type",JdbcType.TINYINT);;
public FieldPath<Byte, App> status = createFieldPath(Byte.class,"status",JdbcType.TINYINT);;
public FieldPath<String, App> description = createFieldPath(String.class,"description",JdbcType.VARCHAR);;
public FieldPath<Date, App> createOn = createFieldPath(Date.class,"create_on",JdbcType.TIMESTAMP);;
public FieldPath<Integer, App> createBy = createFieldPath(Integer.class,"create_by",JdbcType.INTEGER);;
public FieldPath<Date, App> opOn = createFieldPath(Date.class,"op_on",JdbcType.TIMESTAMP);;
public FieldPath<Integer, App> opBy = createFieldPath(Integer.class,"op_by",JdbcType.INTEGER);;
public MetaPath() {
super("t_app");
}
}
}
使用方法:
1)查询
App.MetaPath mp = new App.MetaPath();
SelectStatement<App> st = SelectStatement.newInstance(mp);
st.getRestrictions().add(mp.appName.like(“%2%”)).add(mp.id.isNotNull());
st.setPagination(0, 1);
List<App> list = appMapper.selectByStatement(st);
System.out.println(list.size());
2)修改:
App app = new App();
app.setAppName(“sdfsdfdsfds”);
App.MetaPath ap = new App.MetaPath();
UpdateStatement<App> st = UpdateStatement.newInstance(ap); st.setFieldMetadatas(ap.metaDatas(app));
st.getRestrictions().add(ap.id.eq(app.getId()));
appMapper.updateByStatement(st);
3)删除:
...
此帖只是抛砖引玉(由于jar包中涉及公司信息,暂就到这吧)
基类如下 :
public interface VpmMapper<T,PK> {
/**
* 新增
* @param entity
* @return
*/
int insert(T entity);
/**
* 修改
* @param entity
* @return
*/
int update(T entity);
/**
* 查询
* @param pk
* @return
*/
T selectByPK(PK pk);
/**
* 删除
* @param entity
* @return
*/
int deleteByPK(PK pk);
/**
*
* @param statement
* @return
*/
int insertByStatement(@Param("st")InsertStatement<T> statement);
int updateByStatement(@Param("st")UpdateStatement<T> statement);
int deleteByRestriction(@Param("restrictions")Restrictions<T> restrictions);
int countByRestriction(@Param("restrictions")Restrictions<T> restrictions);