i use the hibernate-distribution-3.6.0.Beta2 to save the data into the as400/DB2. i can look up the data from the DB2 But if i save the data into the DB2 it will report the exception I user the jdbc to save the data ,it is not problem.i guess this is a bug. -----------this is the exception---------------------- org.hibernate.exception.GenericJDBCException: could not execute native bulk manipulation query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:219) at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1309) at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:396) at com.test.ServiceTest.testSession(ServiceTest.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.sql.SQLException: [SQL7008] PWK2870 in NCJPGM not valid for operation. at com.ibm.as400.access.JDError.throwSQLException(JDError.java:687) at com.ibm.as400.access.JDError.throwSQLException(JDError.java:653) at com.ibm.as400.access.AS400JDBCStatement.commonExecute(AS400JDBCStatement.java:920) at com.ibm.as400.access.AS400JDBCPreparedStatement.executeUpdate(AS400JDBCPreparedStatement.java:1401) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:210) ... 31 more ----------------------------------------------------- <session-factory name="ss"> <property name="hibernate.dialect">org.hibernate.dialect.DB2400Dialect</property> <property name="hibernate.connection.driver_class">com.ibm.as400.access.AS400JDBCDriver</property> <property name="hibernate.connection.url">jdbc:as400://****</property> <property name="hibernate.connection.username">****</property> <property name="hibernate.connection.password">****</property> <property name="hibernate.show_sql">true</property> <mapping resource="com/model/Pwk2870.hbm.xml"/> </session-factory>
---------------------------------this is mapping------------------- <hibernate-mapping> <class name="com.model.Pwk2870" table="PWK2870" schema="NCJPGM" catalog="S6513EF0"> <comment>NCDD LUO SAN TEST</comment> <composite-id name="id" class="com.model.Pwk2870Id"> <key-property name="mmcono" type="short"> <column name="MMCONO" precision="3" scale="0" /> </key-property> <key-property name="mmstat" type="string"> <column name="MMSTAT" length="2" /> </key-property> <key-property name="xxtest" type="string"> <column name="XXTEST" length="5" /> </key-property> <key-property name="mmitno" type="string"> <column name="MMITNO" length="15" /> </key-property> <key-property name="mmmabu" type="boolean"> <column name="MMMABU" precision="1" scale="0" /> </key-property> </composite-id> </class> </hibernate-mapping>
----------------------------------------have problem SessionFactory sf = hibernateTemplate.getSessionFactory(); Session session = sf.openSession(); Transaction tx = session.beginTransaction(); String sql = "insert into S6513EF0.NCJPGM.PWK2870(MMCONO,MMITNO) values(68,'B')";
session.createSQLQuery(sql).executeUpdate(); tx.commit(); -------------------no problem--------------------------
java.sql.DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ()); Class.forName("com.ibm.as400.access.AS400JDBCConnection"); con = DriverManager.getConnection("jdbc:as400://****","****","*****"); String sql = "insert into S6513EF0.NCJPGM.PWK2870(MMCONO,MMITNO) values(68,'A')"; PreparedStatement myPreparedStatement = con.prepareStatement(sql); myPreparedStatement.execute(); -----------------------------------------------------------------------hava problem Session session = sf.getCurrentSession(); Pwk2870 p1 = new Pwk2870(); Pwk2870Id pid = new Pwk2870Id(); short s1 = 70; pid.setMmcono(s1); pid.setMmitno("B"); pid.setMmmabu(true); pid.setMmstat("A"); pid.setXxtest("XX"); p1.setId(pid); session.beginTransaction(); session.save(p1); session.beginTransaction().commit(); org.hibernate.exception.GenericJDBCException: could not insert: [com.model.Pwk2870] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2285) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137) at com.test.HibernateTest.saveByObject(HibernateTest.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.sql.SQLException: [SQL7008] PWK2870 in NCJPGM not valid for operation. at com.ibm.as400.access.JDError.throwSQLException(JDError.java:687) at com.ibm.as400.access.JDError.throwSQLException(JDError.java:653) at com.ibm.as400.access.AS400JDBCStatement.commonExecute(AS400JDBCStatement.java:920) at com.ibm.as400.access.AS400JDBCPreparedStatement.executeUpdate(AS400JDBCPreparedStatement.java:1401) at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2265) ... 36 more
|