12:34:11.481 [QuartzScheduler_Worker-1] ERROR c.r.r.jobs.meta.TargetAdzoneMetaJob - T3043562834: TargetAdzoneMetaJob error
org.nutz.dao.DaoException: !Nutz SQL Error: 'INSERT INTO cleaned_zz_target_adzone_meta(serviceProvider,campaignId,campaignName,campaignType,campaignModel,transId,transName,targetId,targetName,targetType,adzoneName,adzoneId,bidprice,targetValue,simulatorType,dayBudget,suggestPrice,createdDate,dateTime,createdOn,updatedOn,bizId,batchNum) VALUES(0,395221245,'zj_campaign_201811011109280e440',2,1,395900779,'zj_trans_201811011109281159b',394100240,'名字小,优质',32768,'图1',34492608,0.0,'190056950',0,300.0,388.16,'2018-11-01','2018-11-01 12:00:08','2018-11-01 12:34:11','2018-11-01 12:34:11','T3043562834','20181101120005622') '
PreparedStatement:
'INSERT INTO cleaned_zz_target_adzone_meta(serviceProvider,campaignId,campaignName,campaignType,campaignModel,transId,transName,targetId,targetName,targetType,adzoneName,adzoneId,bidprice,targetValue,simulatorType,dayBudget,suggestPrice,createdDate,dateTime,createdOn,updatedOn,bizId,batchNum) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) '
CaseMessage=Duplicate entry '390951783-390442611-390628915-34492608-2018-11-01' for key 'PRIMARY'
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
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:159)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:105)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:89)
at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:75)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:73)
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.EntityOperator.exec(EntityOperator.java:56)
at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:193)
at org.nutz.dao.impl.NutDao.insert(NutDao.java:140)
at org.nutz.dao.impl.NutDao.insert(NutDao.java:155)
at org.nutz.dao.impl.NutDao.insertOrUpdate(NutDao.java:1101)
at org.nutz.dao.impl.NutDao.insertOrUpdate(NutDao.java:1072)
at com.rongchi.report.jobs.meta.TargetAdzoneMetaJob$1.run(TargetAdzoneMetaJob.java:113)
at org.nutz.trans.Trans.exec(Trans.java:174)
at org.nutz.trans.Trans.exec(Trans.java:132)
at com.rongchi.report.jobs.meta.TargetAdzoneMetaJob.geneTargetAdzoneMeta(TargetAdzoneMetaJob.java:110)
at com.rongchi.report.jobs.meta.TargetAdzoneMetaJob.execute(TargetAdzoneMetaJob.java:45)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.sql.BatchUpdateException: Duplicate entry '390951783-390442611-390628915-34492608-2018-11-01' for key 'PRIMARY'
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.createBatchUpdateException(SQLError.java:1163)
at com.mysql.jdbc.PreparedStatement.executeBatchedInserts(PreparedStatement.java:1587)
at com.mysql.jdbc.PreparedStatement.executeBatchInternal(PreparedStatement.java:1253)
at com.mysql.jdbc.StatementImpl.executeBatch(StatementImpl.java:970)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:566)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:322)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
... 25 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '390951783-390442611-390628915-34492608-2018-11-01' for key 'PRIMARY'
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:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)
at com.mysql.jdbc.PreparedStatement.executeBatchedInserts(PreparedStatement.java:1548)
... 30 common frames omitted
13 回复
实际要入库的那条数据在数据库中没有查到,报冲突的主键对应的数据在数据库中是有的,本次入库的数据中有这条数据,应该为update才对。 debug时shall_update值为false。之前有一句代码中en的值为null
public <T> T insertOrUpdate(T t, FieldFilter insertFieldFilter, FieldFilter updateFieldFilter) {
if (t == null)
return null;
Object obj = Lang.first(t);
Entity<?> en = getEntity(obj.getClass());
boolean shall_update = false;
MappingField mf = en.getNameField();
if (mf != null) {
Object val = mf.getValue(obj);
if (val != null && fetch(en.getType(), Cnd.where(mf.getName(), "=", val)) != null) {
shall_update = true;
}
}
else if (en.getIdField() != null) {
mf = en.getIdField();
Object val = mf.getValue(obj);
if (val != null && fetch(t) != null) {
shall_update = true;
}
}
else {
shall_update = fetch(t) != null;
}
if (shall_update)
update(t, updateFieldFilter);
else
insert(t, insertFieldFilter);
return t;
}
添加回复
请先登陆