-->
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: SQL insert, update or delete failed (row not found)
PostPosted: Wed Jan 13, 2010 9:20 am 
Newbie

Joined: Wed Jan 13, 2010 7:24 am
Posts: 2
Dear Hibernate users, i am doing an example on <one-to-many> relationship. but i have got the following error:

Hibernate: insert into vendor (vname, vno) values (?, ?)
Hibernate: update customer set cname=?, vid=? where cid=?
org.hibernate.HibernateException:SQL insert, update or delete failed (row not found)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(
NonBatchingBatcher.java:25)
at org.hibernate.persister.BasicEntityPersister.update(BasicEntityPersister.java:1693)
at org.hibernate.persister.BasicEntityPersister.update(BasicEntityPersister.java:1851)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:58)
at org.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:1224)
at org.hibernate.event.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:517)
at org.hibernate.event.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1191)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at Client2.main(Client2.java:39)

in the database no data is inserted either parent's or child's. i am pasting both hbm files and client code. please help me. thanks in advance:

vendor.hbm.xml(parent)
----------------------
<class name="VendorPojo" table="vendor">
<id name="vendorno" column="vno">
<generator class="assigned"/>
</id>
<property name="vendorname" column="vname" length="10"/>
<set name="children" cascade="all">
<key column="vid"/>
<one-to-many class="CustomerPojo"/>
</set>
</class>

customer.hbm.xml(child)
-----------------
<class name="CustomerPojo" table="customer">
<id name="customerid" column="cid">
<generator class="assigned"/>
</id>
<property name="customername" column="cname" length="10"/>
<property name="vendorid" column="vid"/>
</class>

Client2.java
-----------
VendorPojo v = new VendorPojo();
v.setVendorno(new Integer(111));
v.setVendorname("krishna");

CustomerPojo c1 = new CustomerPojo();
c1.setCustomerid(new Integer(100));
c1.setCustomername("k1");

CustomerPojo c2 = new CustomerPojo();
c2.setCustomerid(new Integer(200));
c2.setCustomername("k2");

Set s = new HashSet();
s.add(c1);
s.add(c2);

v.setChildren(s);

Transaction tx = ses.beginTransaction();
ses.save(v);
tx.commit();
ses.close();


Top
 Profile  
 
 Post subject: Re: SQL insert, update or delete failed (row not found)
PostPosted: Wed Jan 13, 2010 3:26 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi krishnamohan,

you might want to have a look at the Transitive persistence section of the Hibernate online documentation.

CU
Froestel

P.S.: Your code snippets would be easier to read if you'd use the BBCode functionality and enclose code in code-tags.

_________________
Have you tried turning it off and on again? [Roy]


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.