NutzCN Logo
问答 dao.insert(list),如果某一条违反唯一约束,返回报错不严谨
发布于 1844天前 作者 abo 2015 次浏览 复制 上一个帖子 下一个帖子
标签:

使用nutz版本是:1.r.65
执行操作:dao.insert(list);
list的数据格式是List<Map<String,Object>>,map数据中有主键字段id;
遇到的小bug:当list中的某一条数据违反唯一约束条件的时候,返回的报错信息默认是list集合的第一条数据,存在误导情况。
.....
现在有个问题,怎么可以在不更改原有nutz版本,和尽量少改动的情况是,使报错信息能正确返回违反唯一约束的数据,而不是默认第一条。
因为报错信息要返回给其他同事看,这个问题导致同事看到的报错信息跟我实际数据库数据情况不一致。导致问题排查困难....

13 回复

jdbc没有反馈是第几条报错的吧

反馈了,默认都是反馈第一条

catch块里捕获的异常信息,包含插入的sql的一条

反馈第一条??? 发日志看看?

项目在公司网络上,等我在外网写个demo

据我所知, 只提示哪个key冲突, 不会提示是第几条

@wendal
经过两项测试:
1.使用oracle测试:
①插入的数据及代码:


@Test public void insertList(){ List<Map<String,Object>> list = new ArrayList<>(); Map<String,Object> m = new HashMap<>(); m.put("id",1); m.put("name","张三"); m.put("age",23); m.put(".table","person"); list.add(m); Map<String,Object> m1 = new HashMap<>(); m1.put("id",2); m1.put("name","李四"); m1.put("age",21); m1.put(".table","person"); list.add(m1); Map<String,Object> m2 = new HashMap<>(); m2.put("id",3); m2.put("name","王五"); m2.put("age",29); m2.put(".table","person"); list.add(m2); Map<String,Object> m3 = new HashMap<>(); m3.put("id",4); m3.put("name","赵六"); m3.put("age",19); m3.put(".table","person"); list.add(m3); String msg = "success"; try { Trans.exec(()->dao1.insert(list)); }catch (Exception e){ e.printStackTrace(); msg = e.getMessage(); } System.out.println(msg); }

②oracle数据库表
结构 id(主键) , name , age
已存在数据:2 李四 21
③步骤一输出的msg信息:

!Nutz SQL Error: 'INSERT INTO person(name,id,age) VALUES('张三',1,23) '

PreparedStatement: 	... 42 more

'INSERT INTO person(name,id,age) VALUES(?,?,?) '
CaseMessage=ORA-00001: 违反唯一约束条件 (NUTZBOOK.PERSON_PK)

2.使用postgres测试
①测试代码及插入数据

@Test
	public void insertList(){
		List<Map<String,Object>> list = new ArrayList<>();
		Map<String,Object> m = new HashMap<>();
		m.put("id",1);
		m.put("name","张三");
		m.put("age",23);
		m.put(".table","person");
		list.add(m);

		Map<String,Object> m1 = new HashMap<>();
		m1.put("id",2);
		m1.put("name","李四");
		m1.put("age",21);
		m1.put(".table","person");
		list.add(m1);

		Map<String,Object> m2 = new HashMap<>();
		m2.put("id",3);
		m2.put("name","王五");
		m2.put("age",29);
		m2.put(".table","person");
		list.add(m2);

		Map<String,Object> m3 = new HashMap<>();
		m3.put("id",4);
		m3.put("name","赵六");
		m3.put("age",19);
		m3.put(".table","person");
		list.add(m3);

		String msg = "success";
		try {
			Trans.exec(()->dao.insert(list));
		}catch (Exception e){
			e.printStackTrace();
			msg = e.getMessage();
		}
		System.out.println(msg);
	}

②数据库表结构
结构:id(主键) name age
已存在数据:2 李四 21
③步骤一输出的msg信息:

!Nutz SQL Error: 'INSERT INTO person(name,id,age) VALUES('张三',1,23) '
PreparedStatement: 
'INSERT INTO person(name,id,age) VALUES(?,?,?) '
CaseMessage=Batch entry 1 INSERT INTO person(name,id,age) VALUES('李四',2,21)  was aborted: 错误: 重复键违反唯一约束"person_pk"
  详细:键值"(id)=(2)" 已经存在  Call getNextException to see other errors in the batch.

经过两次测试:可以确定,在使用oracle插入的时候才会出现此错误
初步推断:可能oracle不支持原生批量插入,nutz进行插入是进行的单条分次插入,导致报错默认第一条数据了

测试oracle输出的日志贴一下

"C:\Program Files\Java\jdk1.8.0_91\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\lib\idea_rt.jar=54474:D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\bin" -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\lib\idea_rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\plugins\junit\lib\junit-rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\plugins\junit\lib\junit5-rt.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\rt.jar;D:\project\aboBook\nutz-postgre\target\test-classes;D:\project\aboBook\nutz-postgre\target\classes;D:\development\m2\repository\com\alibaba\druid\1.0.28\druid-1.0.28.jar;C:\Program Files\Java\jdk1.8.0_91\lib\jconsole.jar;C:\Program Files\Java\jdk1.8.0_91\lib\tools.jar;D:\development\m2\repository\org\postgresql\postgresql\42.2.5\postgresql-42.2.5.jar;D:\development\m2\repository\com\oracle\ojdbc14\10.2.0.1.0\ojdbc14-10.2.0.1.0.jar;D:\development\m2\repository\org\nutz\nutz\1.r.65\nutz-1.r.65.jar;D:\development\m2\repository\org\nutz\nutz-plugins-mock\1.r.65\nutz-plugins-mock-1.r.65.jar;D:\development\m2\repository\junit\junit\4.12\junit-4.12.jar;D:\development\m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;D:\development\m2\repository\org\projectlombok\lombok\1.16.20\lombok-1.16.20.jar;D:\development\m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.skynet.test.TIoc,insertList
[DEBUG] 15:19:32.017 org.nutz.resource.Scans.printLocations(Scans.java:527) - Locations count=40 time use 107ms
[DEBUG] 15:19:32.035 org.nutz.resource.Scans.scan(Scans.java:280) - Found 1 resource by src( ioc/ ) , regex( ^(.+[.])(js|json)$ )
[DEBUG] 15:19:32.036 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:49) - loading [dao.js]
[DEBUG] 15:19:32.040 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:57) - Loaded 4 bean define from path=[ioc/] --> [dao1, dao, dataSource, dataSource1]
[INFO ] 15:19:32.050 org.nutz.ioc.loader.annotation.AnnotationIocLoader.<init>(AnnotationIocLoader.java:50) -  > scan 'com.skynet'
[DEBUG] 15:19:32.062 org.nutz.resource.Scans.scan(Scans.java:280) - Found 5 resource by src( com/skynet/ ) , regex( ^.+[.]class$ )
[INFO ] 15:19:32.066 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:98) -    > add 'mainController                          ' - com.skynet.controller.MainController
[INFO ] 15:19:32.073 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:98) -    > add 'tIoc                                    ' - com.skynet.test.TIoc
[DEBUG] 15:19:32.098 org.nutz.ioc.aop.SimpleAopMaker.<init>(SimpleAopMaker.java:79) - Load AopConfigure for anno=org.nutz.aop.interceptor.async.Async by type=org.nutz.aop.interceptor.async.AsyncAopIocLoader
[INFO ] 15:19:32.103 org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:129) - ... NutIoc init complete
[DEBUG] 15:19:32.104 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get 'tIoc'<class com.skynet.test.TIoc>
[DEBUG] 15:19:32.105 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get '$aop_async'<interface org.nutz.ioc.aop.config.AopConfigration>
[DEBUG] 15:19:32.105 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191) - 	 >> Load definition name=$aop_async
[DEBUG] 15:19:32.107 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject($aop_async) in AsyncAopIocLoader@1076835071
[DEBUG] 15:19:32.108 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:222) - 	 >> Make...'$aop_async'<interface org.nutz.ioc.aop.config.AopConfigration>
[DEBUG] 15:19:32.178 org.nutz.castor.Castors.reload(Castors.java:115) - Using 95 castor for Castors
[DEBUG] 15:19:32.181 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) - Save object '$aop_async' to [app] 
[DEBUG] 15:19:32.189 org.nutz.ioc.aop.SimpleAopMaker.<init>(SimpleAopMaker.java:79) - Load AopConfigure for anno=org.nutz.ioc.aop.Aop by type=org.nutz.ioc.aop.config.impl.AnnotationAopConfigration
[DEBUG] 15:19:32.189 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191) - 	 >> Load definition name=tIoc
[DEBUG] 15:19:32.190 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(tIoc) in AnnotationIocLoader(packages=[com.skynet])
[DEBUG] 15:19:32.190 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:222) - 	 >> Make...'tIoc'<class com.skynet.test.TIoc>
[DEBUG] 15:19:32.190 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) - Save object 'tIoc' to [app] 
[DEBUG] 15:19:32.191 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class com.skynet.test.TIoc without AOP
[DEBUG] 15:19:32.234 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get 'dao'<interface org.nutz.dao.Dao>
[DEBUG] 15:19:32.234 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191) - 	 >> Load definition name=dao
[DEBUG] 15:19:32.235 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(dao) in JsonLoader(paths=[ioc/])
[DEBUG] 15:19:32.235 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:222) - 	 >> Make...'dao'<interface org.nutz.dao.Dao>
[DEBUG] 15:19:32.235 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) - Save object 'dao' to [app] 
[DEBUG] 15:19:32.236 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get 'dataSource'<>
[DEBUG] 15:19:32.237 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191) - 	 >> Load definition name=dataSource
[DEBUG] 15:19:32.238 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(dataSource) in JsonLoader(paths=[ioc/])
[DEBUG] 15:19:32.238 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:222) - 	 >> Make...'dataSource'<>
[DEBUG] 15:19:32.238 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) - Save object 'dataSource' to [app] 
[DEBUG] 15:19:32.262 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class com.alibaba.druid.pool.DruidDataSource without AOP
[INFO ] 15:19:32.564 com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:785) - {dataSource-1} inited
[DEBUG] 15:19:32.576 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class org.nutz.dao.impl.NutDao without AOP
[DEBUG] 15:19:32.577 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get 'dataSource'<>
[DEBUG] 15:19:32.750 org.nutz.dao.jdbc.Jdbcs.<clinit>(Jdbcs.java:90) - Jdbcs init complete
[INFO ] 15:19:32.750 org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:103) - Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
[DEBUG] 15:19:33.199 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:188) - select expert : org.nutz.dao.impl.jdbc.psql.PsqlJdbcExpert
[DEBUG] 15:19:33.205 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:199) - JDBC Driver --> 42.2.5
[DEBUG] 15:19:33.205 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:200) - JDBC Name   --> PostgreSQL JDBC Driver
[DEBUG] 15:19:33.205 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:202) - JDBC URL    --> jdbc:postgresql://localhost:5432/postgres
[DEBUG] 15:19:33.217 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:221) - Database info --> PSQL:[PostgreSQL - 10.6]
[DEBUG] 15:19:33.222 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get 'dao1'<interface org.nutz.dao.Dao>
[DEBUG] 15:19:33.223 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191) - 	 >> Load definition name=dao1
[DEBUG] 15:19:33.223 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(dao1) in JsonLoader(paths=[ioc/])
[DEBUG] 15:19:33.223 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:222) - 	 >> Make...'dao1'<interface org.nutz.dao.Dao>
[DEBUG] 15:19:33.229 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) - Save object 'dao1' to [app] 
[DEBUG] 15:19:33.230 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get 'dataSource1'<>
[DEBUG] 15:19:33.230 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191) - 	 >> Load definition name=dataSource1
[DEBUG] 15:19:33.230 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(dataSource1) in JsonLoader(paths=[ioc/])
[DEBUG] 15:19:33.230 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:222) - 	 >> Make...'dataSource1'<>
[DEBUG] 15:19:33.231 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:64) - Save object 'dataSource1' to [app] 
[DEBUG] 15:19:33.231 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class com.alibaba.druid.pool.DruidDataSource without AOP
[INFO ] 15:19:33.307 com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:785) - {dataSource-2} inited
[DEBUG] 15:19:33.308 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class org.nutz.dao.impl.NutDao without AOP
[DEBUG] 15:19:33.308 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:165) - Get 'dataSource1'<>
[INFO ] 15:19:33.309 org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:103) - Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
[DEBUG] 15:19:33.563 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:188) - select expert : org.nutz.dao.impl.jdbc.oracle.OracleJdbcExpert
[DEBUG] 15:19:33.563 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:199) - JDBC Driver --> 10.2.0.1.0
[DEBUG] 15:19:33.563 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:200) - JDBC Name   --> Oracle JDBC driver
[DEBUG] 15:19:33.564 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:202) - JDBC URL    --> jdbc:oracle:thin:@localhost/orcl
[DEBUG] 15:19:33.564 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:221) - Database info --> ORACLE:[Oracle - Oracle Database 11g Release 11.1.0.0.0 - Production]
[DEBUG] 15:19:35.269 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - INSERT INTO person(name,id,age) VALUES(?,?,?) 
    |  1 | 2 |  3 |
    |----|---|----|
    | 张三 | 1 | 23 |
    | 李四 | 2 | 21 |
    | 王五 | 3 | 29 |
    | 赵六 | 4 | 19 |
  For example:> "INSERT INTO person(name,id,age) VALUES('张三',1,23) "
[DEBUG] 15:19:35.371 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) - SQLException
java.sql.BatchUpdateException: ORA-00001: 违反唯一约束条件 (NUTZBOOK.PERSON_PK)

	at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
	at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:559)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:322)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	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:55)
	at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:193)
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:140)
	at com.skynet.test.TIoc.lambda$insertList$0(TIoc.java:65)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.trans.Trans.exec(Trans.java:132)
	at com.skynet.test.TIoc.insertList(TIoc.java:65)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:33)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
[DEBUG] 15:19:35.374 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:100) - SQL NextException
java.sql.SQLException: ORA-00001: 违反唯一约束条件 (NUTZBOOK.PERSON_PK)

	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
	at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10580)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:559)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:322)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	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:55)
	at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:193)
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:140)
	at com.skynet.test.TIoc.lambda$insertList$0(TIoc.java:65)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.trans.Trans.exec(Trans.java:132)
	at com.skynet.test.TIoc.insertList(TIoc.java:65)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:33)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
!Nutz SQL Error: 'INSERT INTO person(name,id,age) VALUES('张三',1,23) '
PreparedStatement: 
'INSERT INTO person(name,id,age) VALUES(?,?,?) '
CaseMessage=ORA-00001: 违反唯一约束条件 (NUTZBOOK.PERSON_PK)

[INFO ] 15:19:35.379 org.nutz.ioc.impl.NutIoc.depose(NutIoc.java:286) - org.nutz.ioc.impl.NutIoc@18242360 is closing. startup date [19-11-05 15:19:32.101]
[DEBUG] 15:19:35.379 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:108) - Depose object 'dao1' ...
[DEBUG] 15:19:35.379 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:108) - Depose object 'dao' ...
[DEBUG] 15:19:35.379 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:108) - Depose object 'tIoc' ...
[DEBUG] 15:19:35.379 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:108) - Depose object '$aop_async' ...
[DEBUG] 15:19:35.380 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:113) - Depose object 'dataSource1' ...
[INFO ] 15:19:35.382 com.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:1514) - {dataSource-2} closed
[DEBUG] 15:19:35.383 org.nutz.ioc.impl.ScopeContext.clear(ScopeContext.java:113) - Depose object 'dataSource' ...
[INFO ] 15:19:35.383 com.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:1514) - {dataSource-1} closed
[INFO ] 15:19:35.384 org.nutz.ioc.impl.NutIoc.depose(NutIoc.java:300) - org.nutz.ioc.impl.NutIoc@18242360 is deposed. startup date [19-11-05 15:19:32.101]

Process finished with exit code 0

oracle 测试这个信息,返回的报错就有明显的误导性

先报issue吧

已于码云 报 issue

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