order and orderitems as we all known has a one-to-many relationships, here i set order_id and orderitems_id r all auto-incremented by mysql
but when i have created an new order , exception as follows was thrown
and i also checked the database and found that new order was created successfuly with orderitems whose id seemed to have no problem!
net.sf.hibernate.HibernateException: identifier of an instance of com.sirius.webapps.shoppingmall.order.entity.SOrderItem altered from[color=red] 8 to null at [/color]net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2524)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2347)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2340)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2207)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2186)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.sirius.webapps.shoppingmall.hibernate.OrderDAOFactory.create(OrderDAOFactory.java:35)
at test.TestOrder.testAddItemsToOrder(TestOrder.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
|