NutzCN Logo
问答 dao.insert(list) 时,能够支持 list 中放入不同类型的对象吗
发布于 2853天前 作者 佐蓝 2148 次浏览 复制 上一个帖子 下一个帖子
标签:

现在我有一只 cat 和 一只 dog,他们继承了 animal,想当然地把他两放进了 list 然后 insert 和 update,就报了下面这个错。

这里不知道是我的使用方法不对还是不支持这样使用,如果不支持的话是否有其他方法呢。

03-01 16:29:44.533 INFO  [main] org.nutz.lang.eject.EjectByGetter [eject]
			- Fail to value by getter
java.lang.IllegalArgumentException: object is not an instance of declaring class
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_111]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_111]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
	at org.nutz.lang.eject.EjectByGetter.eject(EjectByGetter.java:23) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.entity.field.AbstractEntityField.getValue(AbstractEntityField.java:57) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.sql.pojo.InsertValuesPItem.joinParams(InsertValuesPItem.java:50) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.jdbc.NutPojo.getParamMatrix(NutPojo.java:88) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.sql.NutStatement.forPrint(NutStatement.java:191) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:20) [nutz-1.r.60.jar:?]
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64) [nutz-1.r.60.jar:?]
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:189) [nutz-1.r.60.jar:?]
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:136) [nutz-1.r.60.jar:?]
	at com.nari.nwims.busdown.modules.resource.service.RelationSaveTest.dwRelation(RelationSaveTest.java:60) [test-classes/:?]
	at com.nari.nwims.busdown.modules.resource.service.AnlsConfMsgTest.analysis(AnlsConfMsgTest.java:111) [test-classes/:?]
	at com.nari.nwims.busdown.modules.resource.service.ConfServiceTest.dealWithConf(ConfServiceTest.java:54) [test-classes/:?]
	at com.nari.nwims.busdown.modules.resource.service.ConfServiceTest.testConf(ConfServiceTest.java:82) [test-classes/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_111]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_111]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) [junit-4.11.jar:?]
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.11.jar:?]
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) [junit-4.11.jar:?]
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.11.jar:?]
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) [junit-4.11.jar:?]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) [junit-4.11.jar:?]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) [junit-4.11.jar:?]
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) [junit-4.11.jar:?]
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) [junit-4.11.jar:?]
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) [junit-4.11.jar:?]
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) [junit-4.11.jar:?]
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) [junit-4.11.jar:?]
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:?]
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) [.cp/:?]
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [.cp/:?]
1 回复

不支持的,用foreach循环插入吧

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