-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: joind class use Id generator throw duplicate entry error
PostPosted: Wed Jun 18, 2008 9:38 pm 
Newbie

Joined: Wed Jun 18, 2008 8:45 pm
Posts: 2
Hibernate version:
hibernate-3.2.6.ga
hibernate-annotations-3.3.1.GA
hibernate-entitymanager-3.3.2.GA
hibernate-search-3.0.1.GA
hibernate-validator-3.0.0.GA

Mapping documents:I use annonations
in package-info
Code:
@GenericGenerator(
    name = "IdGenerator",
    strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
    parameters = {
        @Parameter(name = "sequence_name", value = "ID_SEQUENCE"),
        @Parameter(name = "initial_value", value = "1000"),
        @Parameter(name = "increment_size", value = "1")
    }
)


in supperclass LandNode

Code:
@Entity
@Table(name = "LAND_NODE")
@Inheritance(strategy = InheritanceType.JOINED)
@org.hibernate.annotations.BatchSize(size = 20)
public abstract class LandNode<N extends LandNode> implements Comparable {
    @Logger
   private static Log log;
    public static enum SortableProperty {
        name, createdOn,lastModifiedOn,hitCounts,lastHittedOn;
    }

    @Id
    @GeneratedValue(generator="IdGenerator")
   @Column(name = "NODE_ID")
    //@org.hibernate.search.annotations.DocumentId(name = "nodeId")
    protected long id;
   
    @Version
    @Column(name = "OBJ_VERSION", nullable = false)
    protected int version = 0;
   
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "PARENT_NODE_ID", nullable = true)
    //TODO: @org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE)
    @org.hibernate.annotations.ForeignKey(name = "FK_LAND_NODE_PARENT_NODE_ID")
    //@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.JOIN)
    protected LandNode parent;
    ..........

in subclass

Code:
@Entity
@Table(name = "LAND_DISTRICT")
@org.hibernate.annotations.ForeignKey(name = "FK_LAND_DISTRICT_NODE_ID")
@org.hibernate.annotations.BatchSize(size = 20)
//@org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE)
public class District extends LandNode<District> implements
      NestedSetNode<District>, Serializable {
   
   @Column(name = "DESCRIPTION", nullable = true)
    @Length(min = 0, max = 512)
    private String description;

in testng

Code:
@Test
    public void insertDistrictById() throws Exception {
        new FacesRequest() {

            @Override
         protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("entityManager");
                District d = (District)
                        em.createQuery("select d from District d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();
                log.debug("create new district FFF");
                District newDis = new District();
                newDis.setName("FFF");
                newDis.setCreatedBy(em.find(User.class, 1l));
                newDis.setParent(d);
                newDis.setDescription("test district node");
                log.debug("persist new district FFF,Add FFF to " + d.getName());
               
                em.persist(newDis);
                               
                em.flush();
                em.clear();
                log.debug("FFF's ID is " + newDis.getId());
               
                d = (District)
                        em.createQuery("select d from District d where d.id = :id")
                                .setParameter("id", 1l)
                                .getSingleResult();
                assert d.getName().equals("AAA");
                assert d.getNodeInfo().getNsLeft().equals(1l);
                assert d.getNodeInfo().getNsRight().equals(1001l);

                em.clear();
                d = (District)
                        em.createQuery("select d from District d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();
                assert d.getName().equals("CCC");
                assert d.getNodeInfo().getNsLeft().equals(4l);
                assert d.getNodeInfo().getNsRight().equals(11l);

                em.clear();
                d = (District)
                        em.createQuery("select d from District d where d.id = :id")
                                .setParameter("id", newDis.getId())
                                .getSingleResult();
                assert d.getName().equals("FFF");
                assert d.getNodeInfo().getNsLeft().equals(9l);
                assert d.getNodeInfo().getNsRight().equals(10l);
            }
        }.run();
    }

there are some other query and update operation passed.but the method above throw duplicate entry error.


Full stack trace of any exception that occurs:

Code:
[testng] [Parser] Running:
   [testng]   D:\workspace\eclipse\gofit\test-build\AllTests.tng.xml
   [testng] WARN  [org.hibernate.ejb.Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
   [testng] WARN  [org.hibernate.impl.SessionFactoryObjectFactory] InitialContext did not implement EventContext
   [testng] INFO  [cn.bfcc.gofit.test.util.DBUnitSeamTest] >>> Preparing dataset: cn/bfcc/gofit/test/BaseData.dbunit.xml <<<
   [testng] INFO  [cn.bfcc.gofit.test.util.DBUnitSeamTest] Executing test class: cn.bfcc.gofit.test.model.DistrictTests
   [testng] DEBUG [cn.bfcc.gofit.test.util.DBUnitSeamTest] executing DBUnit operation: class org.dbunit.operation.CompositeOperation with dataset: cn/bfcc/gofit/test/BaseData.dbunit.xml
   [testng] DEBUG [org.hibernate.SQL] /* select d from District d where d.id = :id */ select district0_.NODE_ID as NODE1_1_, district0_1_.CREATED_BY_USER_ID as CREATED8_1_, district0_1_.CREATED_ON as CREATED2_1_, district0_1_.HIT_COUNTS as HIT3_1_, district0_1_.LAST_HITTED_ON as LAST4_1_, district0_1_.LAST_MODIFIED_BY_USER_ID as LAST9_1_, district0_1_.LAST_MODIFIED_ON as LAST5_1_, district0_1_.NAME as NAME1_, district0_1_.PARENT_NODE_ID as PARENT10_1_, district0_1_.OBJ_VERSION as OBJ7_1_, district0_.DESCRIPTION as DESCRIPT1_5_, district0_.NS_LEFT as NS2_5_, district0_.NS_RIGHT as NS3_5_, district0_.NS_THREAD as NS4_5_ from LAND_DISTRICT district0_ inner join LAND_NODE district0_1_ on district0_.NODE_ID=district0_1_.NODE_ID where district0_.NODE_ID=?
   [testng] DEBUG [cn.bfcc.gofit.test.util.DBUnitSeamTest] executing DBUnit operation: class org.dbunit.operation.CompositeOperation with dataset: cn/bfcc/gofit/test/BaseData.dbunit.xml
   [testng] DEBUG [org.hibernate.SQL] /* select d from District d where d.id = :id */ select district0_.NODE_ID as NODE1_1_, district0_1_.CREATED_BY_USER_ID as CREATED8_1_, district0_1_.CREATED_ON as CREATED2_1_, district0_1_.HIT_COUNTS as HIT3_1_, district0_1_.LAST_HITTED_ON as LAST4_1_, district0_1_.LAST_MODIFIED_BY_USER_ID as LAST9_1_, district0_1_.LAST_MODIFIED_ON as LAST5_1_, district0_1_.NAME as NAME1_, district0_1_.PARENT_NODE_ID as PARENT10_1_, district0_1_.OBJ_VERSION as OBJ7_1_, district0_.DESCRIPTION as DESCRIPT1_5_, district0_.NS_LEFT as NS2_5_, district0_.NS_RIGHT as NS3_5_, district0_.NS_THREAD as NS4_5_ from LAND_DISTRICT district0_ inner join LAND_NODE district0_1_ on district0_.NODE_ID=district0_1_.NODE_ID where district0_.NODE_ID=?
   [testng] DEBUG [org.hibernate.SQL] /* load cn.bfcc.gofit.model.LandNode */ select landnode0_.NODE_ID as NODE1_1_1_, landnode0_.CREATED_BY_USER_ID as CREATED8_1_1_, landnode0_.CREATED_ON as CREATED2_1_1_, landnode0_.HIT_COUNTS as HIT3_1_1_, landnode0_.LAST_HITTED_ON as LAST4_1_1_, landnode0_.LAST_MODIFIED_BY_USER_ID as LAST9_1_1_, landnode0_.LAST_MODIFIED_ON as LAST5_1_1_, landnode0_.NAME as NAME1_1_, landnode0_.PARENT_NODE_ID as PARENT10_1_1_, landnode0_.OBJ_VERSION as OBJ7_1_1_, landnode0_1_.FULL_NAME as FULL1_2_1_, landnode0_1_.LATITUDE as LATITUDE2_1_, landnode0_1_.LONGITUDE as LONGITUDE2_1_, landnode0_2_.DESCRIPTION as DESCRIPT1_5_1_, landnode0_2_.NS_LEFT as NS2_5_1_, landnode0_2_.NS_RIGHT as NS3_5_1_, landnode0_2_.NS_THREAD as NS4_5_1_, case when landnode0_1_.NODE_ID is not null then 1 when landnode0_2_.NODE_ID is not null then 2 when landnode0_.NODE_ID is not null then 0 end as clazz_1_, landnode1_.NODE_ID as NODE1_1_0_, landnode1_.CREATED_BY_USER_ID as CREATED8_1_0_, landnode1_.CREATED_ON as CREATED2_1_0_, landnode1_.HIT_COUNTS as HIT3_1_0_, landnode1_.LAST_HITTED_ON as LAST4_1_0_, landnode1_.LAST_MODIFIED_BY_USER_ID as LAST9_1_0_, landnode1_.LAST_MODIFIED_ON as LAST5_1_0_, landnode1_.NAME as NAME1_0_, landnode1_.PARENT_NODE_ID as PARENT10_1_0_, landnode1_.OBJ_VERSION as OBJ7_1_0_, landnode1_1_.FULL_NAME as FULL1_2_0_, landnode1_1_.LATITUDE as LATITUDE2_0_, landnode1_1_.LONGITUDE as LONGITUDE2_0_, landnode1_2_.DESCRIPTION as DESCRIPT1_5_0_, landnode1_2_.NS_LEFT as NS2_5_0_, landnode1_2_.NS_RIGHT as NS3_5_0_, landnode1_2_.NS_THREAD as NS4_5_0_, case when landnode1_1_.NODE_ID is not null then 1 when landnode1_2_.NODE_ID is not null then 2 when landnode1_.NODE_ID is not null then 0 end as clazz_0_ from LAND_NODE landnode0_ left outer join LAND_ADDRESS landnode0_1_ on landnode0_.NODE_ID=landnode0_1_.NODE_ID left outer join LAND_DISTRICT landnode0_2_ on landnode0_.NODE_ID=landnode0_2_.NODE_ID left outer join LAND_NODE landnode1_ on landnode0_.PARENT_NODE_ID=landnode1_.NODE_ID left outer join LAND_ADDRESS landnode1_1_ on landnode1_.NODE_ID=landnode1_1_.NODE_ID left outer join LAND_DISTRICT landnode1_2_ on landnode1_.NODE_ID=landnode1_2_.NODE_ID where landnode0_.NODE_ID=?
   [testng] DEBUG [cn.bfcc.gofit.test.model.DistrictTests] create new district FFF
   [testng] DEBUG [org.hibernate.SQL] /* load cn.bfcc.gofit.model.User */ select user0_.USER_ID as USER1_6_0_, user0_.ACTIVATED as ACTIVATED6_0_, user0_.ACTIVATION_CODE as ACTIVATION3_6_0_, user0_.CREATED_ON as CREATED4_6_0_, user0_.EMAIL as EMAIL6_0_, user0_.FIRSTNAME as FIRSTNAME6_0_, user0_.LAST_LOGIN_ON as LAST7_6_0_, user0_.LASTNAME as LASTNAME6_0_, user0_.PASSWORDHASH as PASSWORD9_6_0_, user0_.USER_PROFILE_ID as USER12_6_0_, user0_.USERNAME as USERNAME6_0_, user0_.OBJ_VERSION as OBJ11_6_0_ from USERS user0_ where user0_.USER_ID=?
   [color=red][testng] DEBUG [cn.bfcc.gofit.test.model.DistrictTests] persist new district FFF,Add FFF to CCC
   [testng] DEBUG [org.hibernate.SQL] select next_val id_val from ID_SEQUENCE for update
   [testng] DEBUG [org.hibernate.SQL] update ID_SEQUENCE set next_val= ? where next_val=?
   [testng] DEBUG [org.hibernate.SQL] /* insert cn.bfcc.gofit.model.District */ insert into LAND_NODE (CREATED_BY_USER_ID, CREATED_ON, HIT_COUNTS, LAST_HITTED_ON, LAST_MODIFIED_BY_USER_ID, LAST_MODIFIED_ON, NAME, PARENT_NODE_ID, OBJ_VERSION, NODE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
   [testng] DEBUG [org.hibernate.SQL] /* insert cn.bfcc.gofit.model.District */ insert into LAND_DISTRICT (DESCRIPTION, NS_LEFT, NS_RIGHT, NS_THREAD, NODE_ID) values (?, ?, ?, ?, ?)
   [testng] DEBUG [org.hibernate.SQL] /* insert cn.bfcc.gofit.model.District */ insert into LAND_NODE (CREATED_BY_USER_ID, CREATED_ON, HIT_COUNTS, LAST_HITTED_ON, LAST_MODIFIED_BY_USER_ID, LAST_MODIFIED_ON, NAME, PARENT_NODE_ID, OBJ_VERSION, NODE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
   [testng] WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1062, SQLState: 23000
   [testng] ERROR [org.hibernate.util.JDBCExceptionReporter] Duplicate entry '1000' for key 1[/color]
   [testng] ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
   [testng] org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   [testng]    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
   [testng]    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
   [testng]    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2232)
   [testng]    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
   [testng]    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
   [testng]    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
   [testng]    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
   [testng]    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
   [testng]    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   [testng]    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   [testng]    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   [testng]    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   [testng]    at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:516)
   [testng]    at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
   [testng]    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:250)
   [testng]    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
   [testng]    at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
   [testng]    at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)
   [testng]    at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
   [testng]    at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
   [testng]    at org.jboss.embedded.adapters.LocalOnlyUserTransaction.commit(LocalOnlyUserTransaction.java:96)
   [testng]    at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:341)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:241)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:192)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.invokeApplicationPhase(BaseSeamTest.java:673)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(BaseSeamTest.java:609)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.access$300(BaseSeamTest.java:184)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request$2.doFilter(BaseSeamTest.java:530)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
   [testng]    at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
   [testng]    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
   [testng]    at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:524)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$FacesRequest.run(BaseSeamTest.java:876)
   [testng]    at cn.bfcc.gofit.test.model.DistrictTests.insertDistrictById(DistrictTests.java:111)
   [testng]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   [testng]    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   [testng]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   [testng]    at java.lang.reflect.Method.invoke(Unknown Source)
   [testng]    at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
   [testng]    at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
   [testng]    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
   [testng]    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
   [testng]    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
   [testng]    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
   [testng]    at org.testng.TestRunner.runWorkers(TestRunner.java:678)
   [testng]    at org.testng.TestRunner.privateRun(TestRunner.java:624)
   [testng]    at org.testng.TestRunner.run(TestRunner.java:495)
   [testng]    at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
   [testng]    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
   [testng]    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
   [testng]    at org.testng.SuiteRunner.run(SuiteRunner.java:190)
   [testng]    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
   [testng]    at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
   [testng]    at org.testng.TestNG.run(TestNG.java:699)
   [testng]    at org.testng.TestNG.privateMain(TestNG.java:824)
   [testng]    at org.testng.TestNG.main(TestNG.java:802)
   [testng] Caused by: java.sql.BatchUpdateException: Duplicate entry '1000' for key 1
   [testng]    at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:665)
   [testng]    at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:518)
   [testng]    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
   [testng]    ... 71 more
   [testng] ERROR [org.jboss.seam.jsf.SeamPhaseListener] uncaught exception
   [testng] java.lang.IllegalStateException: Could not commit transaction
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:613)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:341)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:241)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:192)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.invokeApplicationPhase(BaseSeamTest.java:673)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(BaseSeamTest.java:609)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.access$300(BaseSeamTest.java:184)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request$2.doFilter(BaseSeamTest.java:530)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
   [testng]    at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
   [testng]    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
   [testng]    at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
   [testng]    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
   [testng]    at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:524)
   [testng]    at org.jboss.seam.mock.BaseSeamTest$FacesRequest.run(BaseSeamTest.java:876)
   [testng]    at cn.bfcc.gofit.test.model.DistrictTests.insertDistrictById(DistrictTests.java:111)
   [testng]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   [testng]    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   [testng]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   [testng]    at java.lang.reflect.Method.invoke(Unknown Source)
   [testng]    at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
   [testng]    at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
   [testng]    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
   [testng]    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
   [testng]    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
   [testng]    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
   [testng]    at org.testng.TestRunner.runWorkers(TestRunner.java:678)
   [testng]    at org.testng.TestRunner.privateRun(TestRunner.java:624)
   [testng]    at org.testng.TestRunner.run(TestRunner.java:495)
   [testng]    at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
   [testng]    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
   [testng]    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
   [testng]    at org.testng.SuiteRunner.run(SuiteRunner.java:190)
   [testng]    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
   [testng]    at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
   [testng]    at org.testng.TestNG.run(TestNG.java:699)
   [testng]    at org.testng.TestNG.privateMain(TestNG.java:824)
   [testng]    at org.testng.TestNG.main(TestNG.java:802)
   [testng] Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
   [testng]    at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1401)
   [testng]    at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
   [testng]    at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
   [testng]    at org.jboss.embedded.adapters.LocalOnlyUserTransaction.commit(LocalOnlyUserTransaction.java:96)
   [testng]    at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
   [testng]    at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:603)
   [testng]    ... 48 more
   [testng] Caused by: javax.persistence.EntityExistsException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   [testng]    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:605)
   [testng]    at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:525)
   [testng]    at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
   [testng]    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:250)
   [testng]    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:86)
   [testng]    at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
   [testng]    at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1389)
   [testng]    ... 53 more
   [testng] Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   [testng]    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
   [testng]    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
   [testng]    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2232)
   [testng]    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
   [testng]    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
   [testng]    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
   [testng]    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
   [testng]    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
   [testng]    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   [testng]    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   [testng]    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   [testng]    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   [testng]    at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:516)
   [testng]    ... 58 more
   [testng] Caused by: java.sql.BatchUpdateException: Duplicate entry '1000' for key 1
   [testng]    at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:665)
   [testng]    at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:518)
   [testng]    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   [testng]    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
   [testng]    ... 71 more
   [testng] DEBUG [cn.bfcc.gofit.test.util.DBUnitSeamTest] executing DBUnit operation: class org.dbunit.operation.CompositeOperation with dataset: cn/bfcc/gofit/test/BaseData.dbunit.xml
   [testng] DEBUG [org.hibernate.SQL] /* select d from District d where d.id = :id */ select district0_.NODE_ID as NODE1_1_, district0_1_.CREATED_BY_USER_ID as CREATED8_1_, district0_1_.CREATED_ON as CREATED2_1_, district0_1_.HIT_COUNTS as HIT3_1_, district0_1_.LAST_HITTED_ON as LAST4_1_, district0_1_.LAST_MODIFIED_BY_USER_ID as LAST9_1_, district0_1_.LAST_MODIFIED_ON as LAST5_1_, district0_1_.NAME as NAME1_, district0_1_.PARENT_NODE_ID as PARENT10_1_, district0_1_.OBJ_VERSION as OBJ7_1_, district0_.DESCRIPTION as DESCRIPT1_5_, district0_.NS_LEFT as NS2_5_, district0_.NS_RIGHT as NS3_5_, district0_.NS_THREAD as NS4_5_ from LAND_DISTRICT district0_ inner join LAND_NODE district0_1_ on district0_.NODE_ID=district0_1_.NODE_ID where district0_.NODE_ID=?
   [testng] DEBUG [org.hibernate.SQL] /* update cn.bfcc.gofit.model.District */ update LAND_NODE set CREATED_BY_USER_ID=?, HIT_COUNTS=?, LAST_HITTED_ON=?, LAST_MODIFIED_BY_USER_ID=?, LAST_MODIFIED_ON=?, NAME=?, PARENT_NODE_ID=?, OBJ_VERSION=? where NODE_ID=? and OBJ_VERSION=?
   [testng] DEBUG [org.hibernate.SQL] /* select d from District d where d.id = :id */ select district0_.NODE_ID as NODE1_1_, district0_1_.CREATED_BY_USER_ID as CREATED8_1_, district0_1_.CREATED_ON as CREATED2_1_, district0_1_.HIT_COUNTS as HIT3_1_, district0_1_.LAST_HITTED_ON as LAST4_1_, district0_1_.LAST_MODIFIED_BY_USER_ID as LAST9_1_, district0_1_.LAST_MODIFIED_ON as LAST5_1_, district0_1_.NAME as NAME1_, district0_1_.PARENT_NODE_ID as PARENT10_1_, district0_1_.OBJ_VERSION as OBJ7_1_, district0_.DESCRIPTION as DESCRIPT1_5_, district0_.NS_LEFT as NS2_5_, district0_.NS_RIGHT as NS3_5_, district0_.NS_THREAD as NS4_5_ from LAND_DISTRICT district0_ inner join LAND_NODE district0_1_ on district0_.NODE_ID=district0_1_.NODE_ID where district0_.NODE_ID=?
   [testng] DEBUG [cn.bfcc.gofit.test.util.DBUnitSeamTest] executing DBUnit operation: class org.dbunit.operation.CompositeOperation with dataset: cn/bfcc/gofit/test/BaseData.dbunit.xml
   [testng] DEBUG [cn.bfcc.gofit.test.model.DistrictTests] org.jboss.seam.persistence.FullTextEntityManagerProxy@214a7a
   [testng] DEBUG [org.hibernate.SQL] /* select d from District d where d.id = :id */ select district0_.NODE_ID as NODE1_1_, district0_1_.CREATED_BY_USER_ID as CREATED8_1_, district0_1_.CREATED_ON as CREATED2_1_, district0_1_.HIT_COUNTS as HIT3_1_, district0_1_.LAST_HITTED_ON as LAST4_1_, district0_1_.LAST_MODIFIED_BY_USER_ID as LAST9_1_, district0_1_.LAST_MODIFIED_ON as LAST5_1_, district0_1_.NAME as NAME1_, district0_1_.PARENT_NODE_ID as PARENT10_1_, district0_1_.OBJ_VERSION as OBJ7_1_, district0_.DESCRIPTION as DESCRIPT1_5_, district0_.NS_LEFT as NS2_5_, district0_.NS_RIGHT as NS3_5_, district0_.NS_THREAD as NS4_5_ from LAND_DISTRICT district0_ inner join LAND_NODE district0_1_ on district0_.NODE_ID=district0_1_.NODE_ID where district0_.NODE_ID=?
   [testng] DEBUG [org.hibernate.SQL] /* load cn.bfcc.gofit.model.LandNode */ select landnode0_.NODE_ID as NODE1_1_1_, landnode0_.CREATED_BY_USER_ID as CREATED8_1_1_, landnode0_.CREATED_ON as CREATED2_1_1_, landnode0_.HIT_COUNTS as HIT3_1_1_, landnode0_.LAST_HITTED_ON as LAST4_1_1_, landnode0_.LAST_MODIFIED_BY_USER_ID as LAST9_1_1_, landnode0_.LAST_MODIFIED_ON as LAST5_1_1_, landnode0_.NAME as NAME1_1_, landnode0_.PARENT_NODE_ID as PARENT10_1_1_, landnode0_.OBJ_VERSION as OBJ7_1_1_, landnode0_1_.FULL_NAME as FULL1_2_1_, landnode0_1_.LATITUDE as LATITUDE2_1_, landnode0_1_.LONGITUDE as LONGITUDE2_1_, landnode0_2_.DESCRIPTION as DESCRIPT1_5_1_, landnode0_2_.NS_LEFT as NS2_5_1_, landnode0_2_.NS_RIGHT as NS3_5_1_, landnode0_2_.NS_THREAD as NS4_5_1_, case when landnode0_1_.NODE_ID is not null then 1 when landnode0_2_.NODE_ID is not null then 2 when landnode0_.NODE_ID is not null then 0 end as clazz_1_, landnode1_.NODE_ID as NODE1_1_0_, landnode1_.CREATED_BY_USER_ID as CREATED8_1_0_, landnode1_.CREATED_ON as CREATED2_1_0_, landnode1_.HIT_COUNTS as HIT3_1_0_, landnode1_.LAST_HITTED_ON as LAST4_1_0_, landnode1_.LAST_MODIFIED_BY_USER_ID as LAST9_1_0_, landnode1_.LAST_MODIFIED_ON as LAST5_1_0_, landnode1_.NAME as NAME1_0_, landnode1_.PARENT_NODE_ID as PARENT10_1_0_, landnode1_.OBJ_VERSION as OBJ7_1_0_, landnode1_1_.FULL_NAME as FULL1_2_0_, landnode1_1_.LATITUDE as LATITUDE2_0_, landnode1_1_.LONGITUDE as LONGITUDE2_0_, landnode1_2_.DESCRIPTION as DESCRIPT1_5_0_, landnode1_2_.NS_LEFT as NS2_5_0_, landnode1_2_.NS_RIGHT as NS3_5_0_, landnode1_2_.NS_THREAD as NS4_5_0_, case when landnode1_1_.NODE_ID is not null then 1 when landnode1_2_.NODE_ID is not null then 2 when landnode1_.NODE_ID is not null then 0 end as clazz_0_ from LAND_NODE landnode0_ left outer join LAND_ADDRESS landnode0_1_ on landnode0_.NODE_ID=landnode0_1_.NODE_ID left outer join LAND_DISTRICT landnode0_2_ on landnode0_.NODE_ID=landnode0_2_.NODE_ID left outer join LAND_NODE landnode1_ on landnode0_.PARENT_NODE_ID=landnode1_.NODE_ID left outer join LAND_ADDRESS landnode1_1_ on landnode1_.NODE_ID=landnode1_1_.NODE_ID left outer join LAND_DISTRICT landnode1_2_ on landnode1_.NODE_ID=landnode1_2_.NODE_ID where landnode0_.NODE_ID=?




Name and version of the database you are using:mysql 5.0

The generated SQL (show_sql=true):

Code:
[testng] DEBUG [org.hibernate.SQL] /* insert cn.bfcc.gofit.model.District */ insert into LAND_NODE (CREATED_BY_USER_ID, CREATED_ON, HIT_COUNTS, LAST_HITTED_ON, LAST_MODIFIED_BY_USER_ID, LAST_MODIFIED_ON, NAME, PARENT_NODE_ID, OBJ_VERSION, NODE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
   [testng] DEBUG [org.hibernate.SQL] /* insert cn.bfcc.gofit.model.District */ insert into LAND_DISTRICT (DESCRIPTION, NS_LEFT, NS_RIGHT, NS_THREAD, NODE_ID) values (?, ?, ?, ?, ?)
   [testng] DEBUG [org.hibernate.SQL] /* insert cn.bfcc.gofit.model.District */ insert into LAND_NODE (CREATED_BY_USER_ID, CREATED_ON, HIT_COUNTS, LAST_HITTED_ON, LAST_MODIFIED_BY_USER_ID, LAST_MODIFIED_ON, NAME, PARENT_NODE_ID, OBJ_VERSION, NODE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
   [testng] WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1062, SQLState: 23000
   [testng] ERROR [org.hibernate.util.JDBCExceptionReporter] Duplicate entry '1000' for key 1




Debug level Hibernate log excerpt:debug

any suggestion is appreciate!


Top
 Profile  
 
 Post subject: I had fix it
PostPosted: Wed Jun 18, 2008 11:15 pm 
Newbie

Joined: Wed Jun 18, 2008 8:45 pm
Posts: 2
there an exception occurs while I persiste district,because I didn't catch the exception,so there is a second insert into the node.
there is nothing with join and id generator


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.