hi
i am having a TransientObjectException in my application
all related information is given bellow
I am using Hibernate version 2.1
I am using Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
Mapping document-----------------------------
<class name="com.diit.voffice.pfb.client.ClientAddressDto" table="client_add_info">
<id name="pkCode" column="PK_CODE">
<generator class="assigned"/>
</id>
<property name="address1" column="ADD1"/>
<property name="address2" column="ADD2"/>
<many-to-one name="country" column="CNT_CODE" not-null="true"/>
<many-to-one name="city" column="CITY_CODE" not-null="true"/>
<many-to-one name="area" column="AREA_CODE"/>
<property name="zipCode" column="ZIP_CODE"/>
<property name="userId" column="USER_ID"/>
<property name="userDateType" column="USER_DATE" type="date"/>
</class>
The Testing method from the test class---------------------
public void testDelete() throws Exception {
SessionFactory factory = (SessionFactory) ContextHolder.getInstance()
.get(ResourceNames.HIBERNATE_SESSION_FACTORY);
Session session = factory.openSession(pool.getConnection());
log.debug("\n\nTest DELETE...............");
ClientAddressDto dtoClone = (ClientAddressDto) dto.clone();
dto = (ClientAddressDto) dtoClone.clone();
businessObject.delete(session, dto, result);
log.debug("result=" + result);
log.debug(((ClientAddressDto) result.getResultData()));
assertTrue(result.getResultData() != null);
session.flush();
if (result.isSuccess()) {
session.connection().commit();
} else {
session.connection().rollback();
}
pool.releaseConnection(session.connection());
session.close();
}
Original Delete method which i am invoking from the test class-----------
public void delete(Session session, ClientAddressDto dto, Result result)
throws HibernateException {
if (dao.isExists(session, dto)) {
session.clear();
dao.delete(session, dto);
result.setActionMessage("message.deleted.success");
result.setSuccess();
}
else {
result.setActionError("error.record.notfound");
result.setFailure();
}
result.setResultData(dto);
}
The following is the stack trace given by JUnit------------------
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.diit.voffice.cis.loc.AreaDto
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2652)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2644)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.EntityType.isDirty(EntityType.java:165)
at net.sf.hibernate.type.TypeFactory.findDirty(TypeFactory.java:225)
at net.sf.hibernate.persister.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:271)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2390)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2340)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2207)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2186)
at com.diit.voffice.testcase.pfb.TestClientAddress.testDelete(TestClientAddress.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:395)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:279)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:171)
|