NutzCN Logo
问答 opAt 可以更改或者删除掉吗,我没找到在哪定义的,有我也给注释了。
发布于 2661天前 作者 tomcat 1790 次浏览 复制 上一个帖子 下一个帖子
标签:
models

@Table("sys_member_user")
public class AppUser
//extends BaseModel
		implements Serializable {

...
serivces

public interface AppUserService extends BaseService<AppUser>{

}
...
impl
@IocBean(args = {"refer:dao"})
public class AppUserServiceImpl extends BaseServiceImpl<AppUser> implements AppUserService {
    public AppUserServiceImpl(Dao dao) {
        super(dao);
    }
}

log

[DEBUG] 2017-08-03 16:25:42,297 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT COUNT(*) FROM sys_member_user 
[DEBUG] 2017-08-03 16:25:42,343 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM sys_member_user  ORDER BY opAt DESC   LIMIT 0, 10 
[DEBUG] 2017-08-03 16:25:42,443 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) - SQLException
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'opAt' in 'order clause'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
	at com.mysql.jdbc.Util.getInstance(Util.java:408)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2497)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2455)
	at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1369)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2363)
	at com.alibaba.druid.filter.FilterAdapter.statement_executeQuery(FilterAdapter.java:2481)
	at com.alibaba.druid.filter.FilterEventAdapter.statement_executeQuery(FilterEventAdapter.java:302)
	at com.alibaba.druid.filter.FilterChainImpl.statement_executeQuery(FilterChainImpl.java:2360)
	at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeQuery(StatementProxyImpl.java:211)
	at com.alibaba.druid.pool.DruidPooledStatement.executeQuery(DruidPooledStatement.java:140)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:246)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor._exec(CachedNutDaoExecutor.java:317)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:187)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:482)
	at cn.wizzer.framework.base.service.BaseServiceImpl.data(BaseServiceImpl.java:886)
	at cn.wizzer.app.web.modules.controllers.platform.app.AppUserController.data(AppUserController.java:52)
	at cn.wizzer.app.web.modules.controllers.platform.app.AppUserController$FM$data$eea76a7cf14444d7689dde0af953df65.invoke(AppUserController.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:35)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.NutShiroProcessor.process(NutShiroProcessor.java:52)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:36)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:21)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at cn.wizzer.app.web.commons.filter.RouteFilter.doFilter(RouteFilter.java:31)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
[DEBUG] 2017-08-03 16:25:53,036 org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3877) - ClusterManager: Check-in complete.

16 回复

让AppUser不继承超类

@wendal

@Table("sys_member_user")
public class AppUser{
//extends BaseModel implements Serializable
[DEBUG] 2017-08-03 16:32:55,375 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT COUNT(*) FROM sys_member_user 
[DEBUG] 2017-08-03 16:32:55,442 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM sys_member_user  ORDER BY opAt DESC   LIMIT 0, 10 
[DEBUG] 2017-08-03 16:32:55,487 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) - SQLException
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'opAt' in 'order clause'
	

不继承也出现

@vincentwong109 默认的是,我更改以后不是,我不知道在哪改

BaseService里面吧

@wendal

BaseService

/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package cn.wizzer.framework.base.service;

import cn.wizzer.framework.page.Pagination;
import cn.wizzer.framework.page.datatable.DataTableColumn;
import cn.wizzer.framework.page.datatable.DataTableOrder;
import java.util.List;
import java.util.Map;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Condition;
import org.nutz.dao.Dao;
import org.nutz.dao.FieldFilter;
import org.nutz.dao.entity.Record;
import org.nutz.dao.pager.Pager;
import org.nutz.dao.sql.Sql;
import org.nutz.lang.util.NutMap;

public interface BaseService<T> {
	Dao dao();

	int count(Condition arg0);

	int count();

	int count(String arg0, Condition arg1);

	int count(String arg0);

	T fetch(long arg0);

	T fetch(String arg0);

	<T> T fetchLinks(T arg0, String arg1);

	<T> T fetchLinks(T arg0, String arg1, Condition arg2);

	T fetch(Condition arg0);

	T fetchx(Object... arg0);

	boolean exists(Object... arg0);

	<T> T insert(T arg0);

	<T> T insert(T arg0, FieldFilter arg1);

	<T> T insertOrUpdate(T arg0);

	<T> T insertOrUpdate(T arg0, FieldFilter arg1, FieldFilter arg2);

	void insert(String arg0, Chain arg1);

	<T> T fastInsert(T arg0);

	<T> T insertWith(T arg0, String arg1);

	<T> T insertLinks(T arg0, String arg1);

	<T> T insertRelation(T arg0, String arg1);

	int update(Object arg0);

	int updateIgnoreNull(Object arg0);

	int update(Chain arg0, Condition arg1);

	int update(String arg0, Chain arg1, Condition arg2);

	<T> T updateWith(T arg0, String arg1);

	<T> T updateLinks(T arg0, String arg1);

	int updateRelation(Class<?> arg0, String arg1, Chain arg2, Condition arg3);

	int updateWithVersion(Object arg0);

	int updateWithVersion(Object arg0, FieldFilter arg1);

	int updateAndIncrIfMatch(Object arg0, FieldFilter arg1, String arg2);

	int getMaxId();

	int delete(long arg0);

	int delete(int arg0);

	int delete(String arg0);

	void delete(Integer[] arg0);

	void delete(Long[] arg0);

	void delete(String[] arg0);

	int clear();

	int clear(String arg0);

	int clear(Condition arg0);

	int clear(String arg0, Condition arg1);

	int vDelete(String arg0);

	int vDelete(String[] arg0);

	T getField(String arg0, long arg1);

	T getField(String arg0, int arg1);

	T getField(String arg0, String arg1);

	T getField(String arg0, Condition arg1);

	List<T> query(String arg0, Condition arg1);

	List<T> query(Condition arg0);

	List<T> query();

	List<T> query(Condition arg0, String arg1);

	List<T> query(String arg0);

	List<T> query(Condition arg0, String arg1, Pager arg2);

	List<T> query(Condition arg0, Pager arg1);

	String getSubPath(String arg0, String arg1, String arg2);

	int count(Sql arg0);

	List<Record> list(Sql arg0);

	Map getMap(Sql arg0);

	Pagination listPage(Integer arg0, Condition arg1);

	Pagination listPage(Integer arg0, Sql arg1);

	Pagination listPage(Integer arg0, String arg1, Condition arg2);

	Pagination listPage(Integer arg0, int arg1, Condition arg2);

	Pagination listPage(Integer arg0, int arg1, Condition arg2, String arg3);

	Pagination listPage(Integer arg0, int arg1, String arg2, Condition arg3);

	Pagination listPage(Integer arg0, int arg1, Sql arg2);

	NutMap data(int arg0, int arg1, int arg2, List<DataTableOrder> arg3, List<DataTableColumn> arg4, Cnd arg5,
			String arg6);

	NutMap data(int arg0, int arg1, int arg2, List<DataTableOrder> arg3, List<DataTableColumn> arg4, Cnd arg5,
			String arg6, Cnd arg7);

	NutMap data(int arg0, int arg1, int arg2, Sql arg3, Sql arg4);
}

BaseServiceImpl

顺着报错信息也能找到啦

@wendal
BaseServiceImpl

/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package cn.wizzer.framework.base.service;

import cn.wizzer.framework.base.service.BaseService;
import cn.wizzer.framework.page.OffsetPager;
import cn.wizzer.framework.page.Pagination;
import cn.wizzer.framework.page.datatable.DataTableColumn;
import cn.wizzer.framework.page.datatable.DataTableOrder;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.math.NumberUtils;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Condition;
import org.nutz.dao.Dao;
import org.nutz.dao.FieldFilter;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.pager.Pager;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;
import org.nutz.dao.util.Daos;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.service.EntityService;

public class BaseServiceImpl<T> extends EntityService<T> implements BaseService<T> {
	private static int DEFAULT_PAGE_NUMBER = 10;

	public BaseServiceImpl(Dao dao) {
		super(dao);
	}

	public int count(Condition cnd) {
		return this.dao().count(this.getEntityClass(), cnd);
	}

	public int count() {
		return this.dao().count(this.getEntityClass());
	}

	public int count(String tableName, Condition cnd) {
		return this.dao().count(tableName, cnd);
	}

	public int count(String tableName) {
		return this.dao().count(tableName);
	}

	public T fetch(long id) {
		return this.dao().fetch(this.getEntityClass(), id);
	}

	public T fetch(String id) {
		return this.dao().fetch(this.getEntityClass(), id);
	}

	public <T> T fetchLinks(T obj, String regex) {
		return this.dao().fetchLinks(obj, regex);
	}

	public <T> T fetchLinks(T obj, String regex, Condition cnd) {
		return this.dao().fetchLinks(obj, regex, cnd);
	}

	public T fetch(Condition cnd) {
		return this.dao().fetch(this.getEntityClass(), cnd);
	}

	public T fetchx(Object... pks) {
		return this.dao().fetchx(this.getEntityClass(), pks);
	}

	public boolean exists(Object... pks) {
		return null != this.fetchx(pks);
	}

	public <T> T insert(T obj) {
		return this.dao().insert(obj);
	}

	public <T> T insert(T obj, FieldFilter filter) {
		return this.dao().insert(obj, filter);
	}

	public <T> T insertOrUpdate(T obj) {
		return this.dao().insertOrUpdate(obj);
	}

	public <T> T insertOrUpdate(T obj, FieldFilter insertFieldFilter, FieldFilter updateFieldFilter) {
		return this.dao().insertOrUpdate(obj, insertFieldFilter, updateFieldFilter);
	}

	public void insert(String tableName, Chain chain) {
		this.dao().insert(tableName, chain);
	}

	public <T> T fastInsert(T obj) {
		return this.dao().fastInsert(obj);
	}

	public <T> T insertWith(T obj, String regex) {
		return this.dao().insertWith(obj, regex);
	}

	public <T> T insertLinks(T obj, String regex) {
		return this.dao().insertLinks(obj, regex);
	}

	public <T> T insertRelation(T obj, String regex) {
		return this.dao().insertRelation(obj, regex);
	}

	public int update(Object obj) {
		return this.dao().update(obj);
	}

	public int updateIgnoreNull(Object obj) {
		return this.dao().updateIgnoreNull(obj);
	}

	public int update(Chain chain, Condition cnd) {
		return this.dao().update(this.getEntityClass(), chain, cnd);
	}

	public int update(String tableName, Chain chain, Condition cnd) {
		return this.dao().update(tableName, chain, cnd);
	}

	public <T> T updateWith(T obj, String regex) {
		return this.dao().updateWith(obj, regex);
	}

	public <T> T updateLinks(T obj, String regex) {
		return this.dao().updateLinks(obj, regex);
	}

	public int updateRelation(Class<?> classOfT, String regex, Chain chain, Condition cnd) {
		return this.dao().updateRelation(classOfT, regex, chain, cnd);
	}

	public int updateWithVersion(Object obj) {
		return this.dao().updateWithVersion(obj);
	}

	public int updateWithVersion(Object obj, FieldFilter fieldFilter) {
		return this.dao().updateWithVersion(obj, fieldFilter);
	}

	public int updateAndIncrIfMatch(Object obj, FieldFilter fieldFilter, String fieldName) {
		return this.dao().updateAndIncrIfMatch(obj, fieldFilter, fieldName);
	}

	public int getMaxId() {
		return this.dao().getMaxId(this.getEntityClass());
	}

	public int delete(long id) {
		return this.dao().delete(this.getEntityClass(), id);
	}

	public int delete(int id) {
		return this.dao().delete(this.getEntityClass(), (long) id);
	}

	public int delete(String id) {
		return this.dao().delete(this.getEntityClass(), id);
	}

	public void delete(Integer[] ids) {
		this.dao().clear(this.getEntityClass(), Cnd.where("id", "in", ids));
	}

	public void delete(Long[] ids) {
		this.dao().clear(this.getEntityClass(), Cnd.where("id", "in", ids));
	}

	public void delete(String[] ids) {
		this.dao().clear(this.getEntityClass(), Cnd.where("id", "in", ids));
	}

	public int clear() {
		return this.dao().clear(this.getEntityClass());
	}

	public int clear(String tableName) {
		return this.dao().clear(tableName);
	}

	public int clear(Condition cnd) {
		return this.dao().clear(this.getEntityClass(), cnd);
	}

	public int clear(String tableName, Condition cnd) {
		return this.dao().clear(tableName, cnd);
	}

	public int vDelete(String id) {
		return this.dao().update(this.getEntityClass(), Chain.make("delTag", Boolean.valueOf(true)),
				Cnd.where("id", "=", id));
	}

	public int vDelete(String[] ids) {
		return this.dao().update(this.getEntityClass(), Chain.make("delTag", Boolean.valueOf(true)),
				Cnd.where("id", "in", ids));
	}

	public T getField(String fieldName, long id) {
		return Daos.ext(this.dao(), FieldFilter.create(this.getEntityClass(), fieldName)).fetch(this.getEntityClass(),
				id);
	}

	public T getField(String fieldName, int id) {
		return Daos.ext(this.dao(), FieldFilter.create(this.getEntityClass(), fieldName)).fetch(this.getEntityClass(),
				(long) id);
	}

	public T getField(String fieldName, String name) {
		return Daos.ext(this.dao(), FieldFilter.create(this.getEntityClass(), fieldName)).fetch(this.getEntityClass(),
				name);
	}

	public T getField(String fieldName, Condition cnd) {
		return Daos.ext(this.dao(), FieldFilter.create(this.getEntityClass(), fieldName)).fetch(this.getEntityClass(),
				cnd);
	}

	public List<T> query(String fieldName, Condition cnd) {
		return Daos.ext(this.dao(), FieldFilter.create(this.getEntityClass(), fieldName)).query(this.getEntityClass(),
				cnd);
	}

	public List<T> query(Condition cnd) {
		return this.dao().query(this.getEntityClass(), cnd);
	}

	public List<T> query() {
		return this.dao().query(this.getEntityClass(), (Condition) null);
	}

	public List<T> query(Condition cnd, String linkName) {
		List list = this.dao().query(this.getEntityClass(), cnd);
		if (!Strings.isBlank(linkName)) {
			this.dao().fetchLinks(list, linkName);
		}

		return list;
	}

	public List<T> query(String linkName) {
		return this.query((Condition) null, (String) linkName);
	}

	public List<T> query(Condition cnd, String linkName, Pager pager) {
		List list = this.dao().query(this.getEntityClass(), cnd, pager);
		if (!Strings.isBlank(linkName)) {
			this.dao().fetchLinks(list, linkName);
		}

		return list;
	}

	public List<T> query(Condition cnd, Pager pager) {
		return this.dao().query(this.getEntityClass(), cnd, pager);
	}

	public String getSubPath(String tableName, String cloName, String value) {
		final String val = Strings.sNull(value);
		Sql sql = Sqls.create("select " + cloName + " from " + tableName + " where " + cloName + " like \'" + val
				+ "____\' order by " + cloName + " desc");
		sql.setCallback(new SqlCallback() {
			public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
				String rsvalue = val + "0001";
				if (rs != null && rs.next()) {
					rsvalue = rs.getString(1);
					int newvalue = NumberUtils.toInt(rsvalue.substring(rsvalue.length() - 4)) + 1;
					rsvalue = rsvalue.substring(0, rsvalue.length() - 4)
							+ (new DecimalFormat("0000")).format((long) newvalue);
				}

				return rsvalue;
			}
		});
		this.dao().execute(sql);
		return sql.getString();
	}

	public int count(Sql sql) {
		sql.setCallback(new SqlCallback() {
			public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
				int rsvalue = 0;
				if (rs != null && rs.next()) {
					rsvalue = rs.getInt(1);
				}

				return Integer.valueOf(rsvalue);
			}
		});
		this.dao().execute(sql);
		return sql.getInt();
	}

	public List<Record> list(Sql sql) {
		sql.setCallback(Sqls.callback.records());
		this.dao().execute(sql);
		return sql.getList(Record.class);
	}

	public Map getMap(Sql sql) {
		sql.setCallback(new SqlCallback() {
			public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
				HashMap map = new HashMap();

				while (rs.next()) {
					map.put(Strings.sNull(rs.getString(1)), Strings.sNull(rs.getString(2)));
				}

				return map;
			}
		});
		this.dao().execute(sql);
		return (Map) sql.getObject(Map.class);
	}

	public Pagination listPage(Integer pageNumber, Condition cnd) {
		return this.listPage(pageNumber, DEFAULT_PAGE_NUMBER, cnd);
	}

	public Pagination listPage(Integer pageNumber, Sql sql) {
		return this.listPage(pageNumber, DEFAULT_PAGE_NUMBER, sql);
	}

	public Pagination listPage(Integer pageNumber, String tableName, Condition cnd) {
		return this.listPage(pageNumber, DEFAULT_PAGE_NUMBER, tableName, cnd);
	}

	public Pagination listPage(Integer pageNumber, int pageSize, Condition cnd) {
		pageNumber = Integer.valueOf(this.getPageNumber(pageNumber));
		pageSize = this.getPageSize(pageSize);
		Pager pager = this.dao().createPager(pageNumber.intValue(), pageSize);
		List list = this.dao().query(this.getEntityClass(), cnd, pager);
		pager.setRecordCount(this.dao().count(this.getEntityClass(), cnd));
		return new Pagination(pageNumber.intValue(), pageSize, pager.getRecordCount(), list);
	}

	public Pagination listPage(Integer pageNumber, int pageSize, Condition cnd, String fieldName) {
		pageNumber = Integer.valueOf(this.getPageNumber(pageNumber));
		pageSize = this.getPageSize(pageSize);
		Pager pager = this.dao().createPager(pageNumber.intValue(), pageSize);
		List list = Daos.ext(this.dao(), FieldFilter.create(this.getEntityClass(), fieldName))
				.query(this.getEntityClass(), cnd, pager);
		pager.setRecordCount(this.dao().count(this.getEntityClass(), cnd));
		return new Pagination(pageNumber.intValue(), pageSize, pager.getRecordCount(), list);
	}

	public Pagination listPage(Integer pageNumber, int pageSize, String tableName, Condition cnd) {
		pageNumber = Integer.valueOf(this.getPageNumber(pageNumber));
		pageSize = this.getPageSize(pageSize);
		Pager pager = this.dao().createPager(pageNumber.intValue(), pageSize);
		List list = this.dao().query(tableName, cnd, pager);
		pager.setRecordCount(this.dao().count(tableName, cnd));
		return new Pagination(pageNumber.intValue(), pageSize, pager.getRecordCount(), list);
	}

	public Pagination listPage(Integer pageNumber, int pageSize, Sql sql) {
		pageNumber = Integer.valueOf(this.getPageNumber(pageNumber));
		pageSize = this.getPageSize(pageSize);
		Pager pager = this.dao().createPager(pageNumber.intValue(), pageSize);
		pager.setRecordCount((int) Daos.queryCount(this.dao(), sql));
		sql.setPager(pager);
		sql.setCallback(Sqls.callback.records());
		this.dao().execute(sql);
		return new Pagination(pageNumber.intValue(), pageSize, pager.getRecordCount(), sql.getList(Record.class));
	}

	protected int getPageNumber(Integer pageNumber) {
		return Lang.isEmpty(pageNumber) ? 1 : pageNumber.intValue();
	}

	protected int getPageSize(int pageSize) {
		return pageSize == 0 ? DEFAULT_PAGE_NUMBER : pageSize;
	}

	public NutMap data(int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns,
			Cnd cnd, String linkName) {
		NutMap re = new NutMap();
		if (orders != null && orders.size() > 0) {
			Iterator pager = orders.iterator();

			while (pager.hasNext()) {
				DataTableOrder list = (DataTableOrder) pager.next();
				DataTableColumn col = (DataTableColumn) columns.get(list.getColumn());
				cnd.orderBy(Sqls.escapeSqlFieldValue(col.getData()).toString(), list.getDir());
			}
		}

		OffsetPager pager1 = new OffsetPager(start, length);
		re.put("recordsFiltered", Integer.valueOf(this.dao().count(this.getEntityClass(), cnd)));
		List list1 = this.dao().query(this.getEntityClass(), cnd, pager1);
		if (!Strings.isBlank(linkName)) {
			this.dao().fetchLinks(list1, linkName);
		}

		re.put("data", list1);
		re.put("draw", Integer.valueOf(draw));
		re.put("recordsTotal", Integer.valueOf(length));
		return re;
	}

	public NutMap data(int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns,
			Cnd cnd, String linkName, Cnd subCnd) {
		NutMap re = new NutMap();
		if (orders != null && orders.size() > 0) {
			Iterator pager = orders.iterator();

			while (pager.hasNext()) {
				DataTableOrder list = (DataTableOrder) pager.next();
				DataTableColumn col = (DataTableColumn) columns.get(list.getColumn());
				cnd.orderBy(Sqls.escapeSqlFieldValue(col.getData()).toString(), list.getDir());
			}
		}

		OffsetPager pager1 = new OffsetPager(start, length);
		re.put("recordsFiltered", Integer.valueOf(this.dao().count(this.getEntityClass(), cnd)));
		List list1 = this.dao().query(this.getEntityClass(), cnd, pager1);
		if (!Strings.isBlank(linkName)) {
			if (subCnd != null) {
				this.dao().fetchLinks(list1, linkName, subCnd);
			} else {
				this.dao().fetchLinks(list1, linkName);
			}
		}

		re.put("data", list1);
		re.put("draw", Integer.valueOf(draw));
		re.put("recordsTotal", Integer.valueOf(length));
		return re;
	}

	public NutMap data(int length, int start, int draw, Sql countSql, Sql orderSql) {
		NutMap re = new NutMap();
		OffsetPager pager = new OffsetPager(start, length);
		pager.setRecordCount((int) Daos.queryCount(this.dao(), countSql));
		orderSql.setPager(pager);
		orderSql.setCallback(Sqls.callback.records());
		this.dao().execute(orderSql);
		re.put("recordsFiltered", Integer.valueOf(pager.getRecordCount()));
		re.put("data", orderSql.getList(Record.class));
		re.put("draw", Integer.valueOf(draw));
		re.put("recordsTotal", Integer.valueOf(length));
		return re;
	}
}

检查下
AppUserController.data()

@vincentwong109 没找到原因

AppUserService.data(length, start, draw, order, columns, cnd, null);

@qq_25fdeb50 AppUserController 查询这方法贴出来,也检查下页面有没有传排序字段

是jqdatatable吗?那可能在你的页面中

不继承超类后,你表删除了么?

添加回复
请先登陆
回到顶部