-->
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.  [ 6 posts ] 
Author Message
 Post subject: ids for this class must be manually assigned before calling
PostPosted: Wed Jul 20, 2005 4:53 am 
Newbie

Joined: Wed Jul 20, 2005 4:43 am
Posts: 4
First the needed data ^^:

Hibernate version: 3

Full stack trace of any exception that occurs:
[junit] [springtest] ERROR [main] AbstractBatcher.doExecuteBatch(60) | Exception executing batch:
[junit] org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
[junit] at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
[junit] at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
[junit] at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
[junit] at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
[junit] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
[junit] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
[junit] at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
[junit] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
[junit] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
[junit] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
[junit] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
[junit] at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:488)
[junit] at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java
:435)
[junit] at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectS
upport.java:258)
[junit] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
[junit] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
[junit] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
[junit] at $Proxy5.saveClient(Unknown Source)
[junit] at com.springtest.webapp.action.ClientForm.save(ClientForm.java:57)
[junit] at com.springtest.webapp.action.ClientFormTest.testSave(ClientFormTest.java:58)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
[junit] [springtest] ERROR [main] AbstractFlushingEventListener.performExecutions(277) | Could not synchronize database state with sessi
on
[junit] org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
[junit] at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
[junit] at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
[junit] at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
[junit] at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
[junit] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
[junit] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
[junit] at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
[junit] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
[junit] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
[junit] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
[junit] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
[junit] at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:488)
[junit] at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java
:435)
[junit] at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectS
upport.java:258)
[junit] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
[junit] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
[junit] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
[junit] at $Proxy5.saveClient(Unknown Source)
[junit] at com.springtest.webapp.action.ClientForm.save(ClientForm.java:57)
[junit] at com.springtest.webapp.action.ClientFormTest.testSave(ClientFormTest.java:58)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
[junit] [springtest] DEBUG [main] ClientFormTest.testRemove(63) | testing remove...
[junit] ------------- ---------------- ---------------
[junit] Testcase: testAdd(com.springtest.webapp.action.ClientFormTest): Caused an ERROR
[junit] ids for this class must be manually assigned before calling save(): com.springtest.model.Client; nested exception is org.hiberna
te.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.springtest.model.Client

[junit] org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save():
com.springtest.model.Client; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assign
ed before calling save(): com.springtest.model.Client
[junit] org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.springte
st.model.Client
[junit] at org.hibernate.id.Assigned.generate(Assigned.java:32)
[junit] at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:85)
[junit] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.
java:184)
[junit] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
[junit] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
[junit] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
[junit] at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
[junit] at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:463)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:615)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:612)
[junit] at com.springtest.dao.hibernate.ClientDAOHibernate.saveClient(ClientDAOHibernate.java:29)
[junit] at com.springtest.service.impl.ClientManagerImpl.saveClient(ClientManagerImpl.java:26)
[junit] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:288)
[junit] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
[junit] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
[junit] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
[junit] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
[junit] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
[junit] at $Proxy5.saveClient(Unknown Source)
[junit] at com.springtest.webapp.action.ClientForm.save(ClientForm.java:57)
[junit] at com.springtest.webapp.action.ClientFormTest.testAdd(ClientFormTest.java:31)


[junit] Testcase: testSave(com.springtest.webapp.action.ClientFormTest): Caused an ERROR
[junit] Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1; nested exception is org.hibernate.Sta
leStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
[junit] org.springframework.orm.hibernate3.HibernateSystemException: Batch update returned unexpected row count from update: 0 actual ro
w count: 0 expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 act
ual row count: 0 expected: 1
[junit] org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
[junit] at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
[junit] at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
[junit] at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
[junit] at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
[junit] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
[junit] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
[junit] at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
[junit] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
[junit] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
[junit] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
[junit] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
[junit] at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:488)
[junit] at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java
:435)
[junit] at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectS
upport.java:258)
[junit] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
[junit] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
[junit] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
[junit] at $Proxy5.saveClient(Unknown Source)
[junit] at com.springtest.webapp.action.ClientForm.save(ClientForm.java:57)
[junit] at com.springtest.webapp.action.ClientFormTest.testSave(ClientFormTest.java:58)


Name and version of the database you are using: MySQL 4.1


My mapping file: <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="com.springtest.model.Client"
table="client"
>

<id
name="client"
column="client"
type="java.lang.String"
length="3"
unsaved-value="version"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Client.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="clientname"
type="java.lang.String"
update="true"
insert="true"
column="clientname"
length="80"
not-null="true"
/>

<property
name="inconsistentdb"
type="java.lang.String"
update="true"
insert="true"
column="inconsistentdb"
length="1"
not-null="false"
/>

<property
name="matchcodedebi"
type="java.lang.String"
update="true"
insert="true"
column="matchcodedebi"
length="1"
not-null="false"
/>

<property
name="matchcodecred"
type="java.lang.String"
update="true"
insert="true"
column="matchcodecred"
length="1"
not-null="false"
/>

<property
name="matchcodegl"
type="java.lang.String"
update="true"
insert="true"
column="matchcodegl"
length="1"
not-null="false"
/>

<property
name="pmselectioncode"
type="java.lang.String"
update="true"
insert="true"
column="pmselectioncode"
length="1"
not-null="false"
/>

<property
name="credbalacctstmt"
type="java.lang.String"
update="true"
insert="true"
column="credbalacctstmt"
length="1"
not-null="false"
/>

<property
name="bankstatus"
type="java.lang.String"
update="true"
insert="true"
column="bankstatus"
length="1"
not-null="false"
/>

<property
name="creationdate"
type="java.sql.Timestamp"
update="false"
insert="true"
column="creationdate"
not-null="true"
/>

<property
name="datelastupdate"
type="java.sql.Timestamp"
update="true"
insert="true"
column="datelastupdate"
not-null="false"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Client.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


so my question: How do I assign manually a value?

greets
Kirashet


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 5:58 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Well, this is the German forum, but I'll answer in English though.

The same way you assign a value in Java.
Code:
Client client = new Client();
client.setId("abc");


Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 6:30 am 
Newbie

Joined: Wed Jul 20, 2005 4:43 am
Posts: 4
Danke für die Antwort.
Vor lauter Englisch hab ich vergessen in Deutsch zu schreiben ^^

Werd gleich mal deinen Vorschlag ausprobieren.

Gruß
Ali


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 8:14 am 
Newbie

Joined: Wed Jul 20, 2005 4:43 am
Posts: 4
Hi,

mein Objekt hat gar keine setID() Methode. Hmm.....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 8:27 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Dann brauchst du eben eine solche Methode. Wie willst du sonst IDs zuweisen, wenn du im Mapping sagst, dass du sie selber zuweisen möchtest (<generator class="assigned">)?

Du solltest mal die Dokumentation lesen, insbesondere das Kapitel, was sich mit IDs beschäftigt.

Schöne Grüße
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 10:11 am 
Newbie

Joined: Wed Jul 20, 2005 4:43 am
Posts: 4
alles klar.
Problem wurde gelöst.
Vielen herzlichen Dank, sven ^^


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.