I'm using Jboss3.2.1 with Hibernate2.1 and MySql4(MySQL Connector/J 3.0) and these are my mapping file
For Class MemberHibernate
<hibernate-mapping> <class name="com.netplus.pprincess.hibernate.MemberHibernate" table="MEMBERS"> ... ... <set name="faverites" table="FAVERITES" lazy="false" inverse="true" cascade="all" sort="unsorted"> <key column="memberId"></key> <one-to-many class="com.netplus.pprincess.hibernate.FaveriteHibernate" /> </set> ......
For Class FaveriteHibernate
<hibernate-mapping> <class name="com.netplus.pprincess.hibernate.FaveriteHibernate" table="FAVERITES" > <id name="favId" unsaved-value="null" > <generator class="assigned"> </generator> </id>
<property name="faverite" type="java.lang.String" column="faverite" not-null="false" unique="false" />
<property name="memberId" type="java.lang.Long" column="memberId" not-null="false" unique="false" /> <!-- To add non XDoclet properties, create a file named hibernate-properties-FaveriteHibernate.xml containing the additional properties and place it in your merge dir. --> </class> </hibernate-mapping>
My problem is once I try to set member's Faverite like this
faverite.setFavId(new Long(1)); faverite.setFaverite("faverite"); faverite.setMemberId(member.getMemberId()); member.getFaverites().add(faverite);
I have got this complain in Jboss terminal
20:32:42,425 ERROR [SessionImpl] Could not synchronize database state with session
net.sf.hibernate.HibernateException: Batch update row count wrong: 0
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:65)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:118)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:55)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:105)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:686)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:668)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:53)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2306)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2260)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2185)
at net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:52)
at com.netplus.hibernate.dao.impl.MemberDAOImpl.update(MemberDAOImpl.java:137)
Can anyone give me some suggestions, I've tried to look around in this forum but I can't get any idea, except set Batch_Size=0 ,however I really don't know how to set it in Jboss service and this is my Jboss service file
-->
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=hibernate">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
<attribute name="MapResources">com/netplus/pprincess/hibernate/AddressHibernate.hbm.xml,com/netplus/pprincess/hibernate/MemberHibernate.hbm.xml,com/netplus/pprincess/hibernate/FaveriteHibernate.hbm.xml</attribute>
<attribute name="JndiName">java:/PPrincessHibernateFactory</attribute>
<attribute name="Datasource">java:/PPrincessDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>
</mbean>
</server>
Thanks so much
_________________ <name>arin</name>
<at>netplus software</at>
|