@Inject protected Dao dao;
public void execute(JobExecutionContext context) throws JobExecutionException {
log.debug("clean Non-Active User , start");
Date deadtime = new Date(System.currentTimeMillis() - 5*60*1000L); // 一天, 测试的时候可以改成1小时之类的
Cnd cnd = Cnd.where("userId", ">", 10).and("createTime", "<", deadtime).and(Cnd.exps("emailChecked", "=", false).or("email", "IS", null));
int deleted = dao.clear(UserProfile.class, cnd);
log.debugf("delete %d UserProfile", deleted);
Sql sql = Sqls.create("delete from $user_table where id > 10 and not exists (select 1 from $user_profile_table where $user_table.id = uid ) and ct < @deadtime");
sql.vars().set("user_table", dao.getEntity(User.class).getTableName());
sql.vars().set("user_profile_table", dao.getEntity(UserProfile.class).getTableName());
sql.params().set("deadtime", deadtime);
dao.execute(sql);
log.debugf("delete %d User", sql.getUpdateCount());
log.debug("clean Non-Active User , Done");
}
java.lang.NoSuchMethodError: org.nutz.dao.Dao.execute(Lorg/nutz/dao/sql/Sql;)Lorg/nutz/dao/sql/Sql;
at net.wendal.nutzbook.quartz.job.CleanNonActiveUserJob.execute(CleanNonActiveUserJob.java:38)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
2015-10-29 13:34:00,011 org.quartz.core.ErrorLogger.schedulerError(QuartzScheduler.java:2425) ERROR - Job (DEFAULT.6da64b5bd2ee-eea58502-b67e-4bec-a715-7c9645e300ea threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NoSuchMethodError: org.nutz.dao.Dao.execute(Lorg/nutz/dao/sql/Sql;)Lorg/nutz/dao/sql/Sql;]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.NoSuchMethodError: org.nutz.dao.Dao.execute(Lorg/nutz/dao/sql/Sql;)Lorg/nutz/dao/sql/Sql;
at net.wendal.nutzbook.quartz.job.CleanNonActiveUserJob.execute(CleanNonActiveUserJob.java:38)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
... 1 more