-->
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.  [ 1 post ] 
Author Message
 Post subject: Row not found
PostPosted: Thu Mar 24, 2005 2:09 pm 
Newbie

Joined: Fri Mar 18, 2005 3:06 pm
Posts: 2
Location: St Louis
I receive the below exception when trying to do some simple testing with Hibernate. I'm new to Hibernate and just trying to get a feel for how it works and how we might be able to take advantage of it. The persistence works OK when I have just one table mapped (Test_Sro), but I get the below exception as soon as I try to add a new class and associated table using a one-to-one relationship.

For this example, the Test_Sro table is the parent table and the Test_Caller is the child table. The Test_Sro table maps to the Sro class, adn the Test_Caller table maps to the Contact class. The Test_Caller should have a primary key assigned that is equal to the primary key of the Test_Sro record inserted to the database.

In the below code, a row is inserted to the Test_Sro table, but nothing is inserted to the Test_Caller table.

Can anyone help with how my mapping needs to be changed?

Hibernate version: 2.1.7c

Mapping documents:
<hibernate-mapping>
<class name="HibernateTest.Sro" table="TEST_SRO">
<id name="id" column="SRO_NUMBER" type="integer"><generator class="increment"></generator></id>
<property name="state" type="integer" column="STATE" />
<component name="workingTn" class="HibernateTest.Tn">
<property name="npa" type="string" column="WORKING_NPA" />
<property name="nxx" type="string" column="WORKING_NXX" />
<property name="line" type="string" column="WORKING_LINE" />
</component>
<one-to-one name="caller" class="HibernateTest.Contact" cascade="all"/>
</class>
<class name="HibernateTest.Contact" table="TEST_CALLER">
<id name="id" column="SRO_NUMBER" type="integer"><generator class="foreign"><param name="property">sro</param></generator></id>
<property name="name" column="NAME" type="string"/>
<component name="tn" class="HibernateTest.Tn">
<property name="npa" type="string" column="CALLER_NPA" />
<property name="nxx" type="string" column="CALLER_NXX" />
<property name="line" type="string" column="CALLER_LINE" />
</component>
<one-to-one name="sro" class="HibernateTest.Sro" constrained="true"></one-to-one>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Session session = sessions.openSession(connection);
Transaction transaction = session.beginTransaction();

// Create SRO & set attributes
Sro sro = new Sro();
sro.setState(2);
Tn tn = new Tn("314", "555", "1212");
sro.setWorkingTn(tn);

Contact caller = new Contact();
caller.setName("John Doe");
caller.setSro(sro);
Tn callerTn = new Tn("636", "300", "4444");
caller.setTn(callerTn);
sro.setCaller(caller);

// Save the SRO and commit the database work.
session.save(sro);
transaction.commit();
session.close();

Full stack trace of any exception that occurs:
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:663)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:623)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2392)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at HibernateTest.TestSro.testSaveWithContact(TestSro.java:123)
at java.lang.reflect.Method.invoke(Native Method)
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:329)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151)

Name and version of the database you are using: Oracle 9i


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

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.