I have a many-to-one mapping betweeen RequestStatus and Request classes. Request doesn't have any knowledge of RequestStatus class. Please let me know why am I not seeing rows written in the database.
Hibernate version:
2.1.6
Mapping documents:
RequestStatus.hbm.xml
<many-to-one name="requestVO" class="com.aol.ic.art.data.vo.RequestVO" column="REQUESTID" cascade="all"/>
Code between sessionFactory.openSession() and session.close():
TestCode:
Code:
public static void testCreateRequestStatus(Long requestId) throws ARTException{
logger.info("In testCreateRequestStatus");
String state = "PENDING_APPROVAL";
Calendar cal = new GregorianCalendar();
RequestVO r = (RequestVO) testFind(requestId);
RequestStatusVO requestStatusVO = new RequestStatusVO(state, cal);
requestStatusVO.setRequestVO(r);
AssetRequestToolDAOUtils.create(requestStatusVO);
logger.info("After creating requestStatusVO");
logger.info("Saving RequestStatusVO");
HibernateUtil.commitTransaction();
}
HibernateUtil.beginTransaction();
HibernateUtil.currentSession().saveOrUpdate(requestVO);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
HibernateUtil.beginTransaction();
HibernateUtil.currentSession().saveOrUpdate(requestStatusVO);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Oracle 8.1.7
Debug level Hibernate log excerpt:
2004-08-16 16:49:34 INFO TestRequestDAOUtils.testCreateRequestStatus(?) - In testCreateRequestStatus
2004-08-16 16:49:34 DEBUG SessionImpl.doLoadByClass(1982) - loading [com.aol.ic.art.data.vo.RequestVO#20]
2004-08-16 16:49:34 DEBUG SessionImpl.doLoad(2079) - attempting to resolve [com.aol.ic.art.data.vo.RequestVO#20]
2004-08-16 16:49:34 DEBUG SessionImpl.doLoad(2112) - object not resolved in any cache [com.aol.ic.art.data.vo.RequestVO#20]
2004-08-16 16:49:34 DEBUG EntityPersister.load(416) - Materializing entity: [com.aol.ic.art.data.vo.RequestVO#20]
2004-08-16 16:49:34 DEBUG BatcherImpl.logOpenPreparedStatement(196) - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-08-16 16:49:34 DEBUG BatcherImpl.getPreparedStatement(237) - select requestvo0_.ID as ID0_, requestvo0_.REQUESTORDN as REQUESTO2_0_, requestvo0_.CUSTOMERDN as CUSTOMERDN0_, requestvo0_.FULFILLMEN
TBUILDINGDN as FULFILLM4_0_, requestvo0_.FULFILLMENTROOMNUMBER as FULFILLM5_0_, requestvo0_.LASTAPPROVERDN as LASTAPPR6_0_, requestvo0_.NEXTAPPROVERROLEDN as NEXTAPPR7_0_, requestvo0_.TICKETNUMBER as
TICKETNU8_0_, requestvo0_.STATUS as STATUS0_, requestvo0_.TYPE as TYPE0_, requestvo0_.COMMENTS as COMMENTS0_ from REQUEST requestvo0_ where requestvo0_.ID=?
Hibernate: select requestvo0_.ID as ID0_, requestvo0_.REQUESTORDN as REQUESTO2_0_, requestvo0_.CUSTOMERDN as CUSTOMERDN0_, requestvo0_.FULFILLMENTBUILDINGDN as FULFILLM4_0_, requestvo0_.FULFILLMENTROO
MNUMBER as FULFILLM5_0_, requestvo0_.LASTAPPROVERDN as LASTAPPR6_0_, requestvo0_.NEXTAPPROVERROLEDN as NEXTAPPR7_0_, requestvo0_.TICKETNUMBER as TICKETNU8_0_, requestvo0_.STATUS as STATUS0_, requestvo
0_.TYPE as TYPE0_, requestvo0_.COMMENTS as COMMENTS0_ from REQUEST requestvo0_ where requestvo0_.ID=?
2004-08-16 16:49:34 DEBUG BatcherImpl.getPreparedStatement(241) - preparing statement
2004-08-16 16:49:34 DEBUG NullableType.nullSafeSet(46) - binding '20' to parameter: 1
2004-08-16 16:49:34 DEBUG Loader.doQuery(197) - processing result set
2004-08-16 16:49:34 DEBUG Loader.getRow(405) - result row: 20
2004-08-16 16:49:34 DEBUG Loader.loadFromResultSet(536) - Initializing object from ResultSet: 20
2004-08-16 16:49:34 DEBUG Loader.hydrate(605) - Hydrating entity: com.aol.ic.art.data.vo.RequestVO#20
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'requestorDn' as column: REQUESTO2_0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'customerDn' as column: CUSTOMERDN0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning '200200' as column: FULFILLM4_0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'nextApproverRoleDn' as column: FULFILLM5_0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'lastApproverDn' as column: LASTAPPR6_0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'fulfillmentBuildingDn' as column: NEXTAPPR7_0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'ticketNumber' as column: TICKETNU8_0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'OPEN' as column: STATUS0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'SOFTWARE' as column: TYPE0_
2004-08-16 16:49:34 DEBUG NullableType.nullSafeGet(68) - returning 'comments' as column: COMMENTS0_
2004-08-16 16:49:34 DEBUG Loader.doQuery(226) - done processing result set (1 rows)
2004-08-16 16:49:34 DEBUG BatcherImpl.logClosePreparedStatement(203) - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-08-16 16:49:34 DEBUG BatcherImpl.closePreparedStatement(261) - closing statement
2004-08-16 16:49:34 DEBUG Loader.doQuery(239) - total objects hydrated: 1
2004-08-16 16:49:34 DEBUG SessionImpl.initializeEntity(2198) - resolving associations for [com.aol.ic.art.data.vo.RequestVO#20]
2004-08-16 16:49:34 DEBUG SessionImpl.getCollection(3929) - creating collection wrapper:[com.aol.ic.art.data.vo.RequestVO.products#20]
2004-08-16 16:49:34 DEBUG SessionImpl.initializeEntity(2222) - done materializing entity [com.aol.ic.art.data.vo.RequestVO#20]
2004-08-16 16:49:34 DEBUG SessionImpl.initializeNonLazyCollections(3112) - initializing non-lazy collections
2004-08-16 16:49:34 INFO TestRequestDAOUtils.testFind(?) - requestorDn.customerDn.comments.200200.nextApproverRoleDn.lastApproverDn.fulfillmentBuildingDn.OPEN.ticketNumber.REQUEST
2004-08-16 16:49:34 DEBUG HibernateUtil.beginTransaction(?) - Starting new database transaction in this thread.
2004-08-16 16:49:34 DEBUG JDBCTransaction.begin(37) - begin
2004-08-16 16:49:34 DEBUG JDBCTransaction.begin(41) - current autocommit status:false
2004-08-16 16:49:34 DEBUG SessionImpl.saveOrUpdate(1386) - saveOrUpdate() unsaved instance
2004-08-16 16:49:34 DEBUG BatcherImpl.logOpenPreparedStatement(196) - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-08-16 16:49:34 DEBUG BatcherImpl.getPreparedStatement(237) - select RSTATE_SEQUENCE.nextval from dual
Hibernate: select RSTATE_SEQUENCE.nextval from dual
2004-08-16 16:49:34 DEBUG BatcherImpl.getPreparedStatement(241) - preparing statement
2004-08-16 16:49:34 DEBUG SequenceGenerator.generate(81) - Sequence identifier generated: 11
2004-08-16 16:49:34 DEBUG BatcherImpl.logClosePreparedStatement(203) - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-08-16 16:49:34 DEBUG BatcherImpl.closePreparedStatement(261) - closing statement
2004-08-16 16:49:34 DEBUG SessionImpl.saveWithGeneratedIdentifier(778) - generated identifier: 11
2004-08-16 16:49:34 DEBUG SessionImpl.doSave(825) - saving [com.aol.ic.art.data.vo.RequestStatusVO#11]
2004-08-16 16:49:34 DEBUG Cascades.cascade(497) - processing cascades for: com.aol.ic.art.data.vo.RequestStatusVO
2004-08-16 16:49:34 DEBUG Cascades$4.cascade(113) - cascading to saveOrUpdate()
2004-08-16 16:49:34 DEBUG SessionImpl.saveOrUpdate(1371) - saveOrUpdate() persistent instance
2004-08-16 16:49:34 DEBUG Cascades.cascade(506) - done processing cascades for: com.aol.ic.art.data.vo.RequestStatusVO
2004-08-16 16:49:34 DEBUG Cascades.cascade(497) - processing cascades for: com.aol.ic.art.data.vo.RequestStatusVO
2004-08-16 16:49:34 DEBUG Cascades.cascade(506) - done processing cascades for: com.aol.ic.art.data.vo.RequestStatusVO
2004-08-16 16:49:34 DEBUG HibernateUtil.commitTransaction(?) - Committing database transaction of this thread.
2004-08-16 16:49:34 DEBUG JDBCTransaction.commit(59) - commit
2004-08-16 16:49:34 DEBUG SessionImpl.flushEverything(2242) - flushing session
2004-08-16 16:49:34 DEBUG Cascades.cascade(497) - processing cascades for: com.aol.ic.art.data.vo.RequestStatusVO
2004-08-16 16:49:34 DEBUG Cascades$4.cascade(113) - cascading to saveOrUpdate()
2004-08-16 16:49:34 DEBUG SessionImpl.saveOrUpdate(1371) - saveOrUpdate() persistent instance
2004-08-16 16:49:34 DEBUG Cascades.cascade(506) - done processing cascades for: com.aol.ic.art.data.vo.RequestStatusVO
2004-08-16 16:49:34 DEBUG SessionImpl.flushEntities(2435) - Flushing entities and processing referenced collections
2004-08-16 16:49:34 DEBUG SessionImpl.updateReachableCollection(2880) - Collection found: [com.aol.ic.art.data.vo.RequestVO.products#10], was: [com.aol.ic.art.data.vo.RequestVO.products#10]
2004-08-16 16:49:34 DEBUG SessionImpl.updateReachableCollection(2880) - Collection found: [com.aol.ic.art.data.vo.RequestVO.products#20], was: [com.aol.ic.art.data.vo.RequestVO.products#20]
2004-08-16 16:49:34 DEBUG SessionImpl.flushCollections(2776) - Processing unreferenced collections
2004-08-16 16:49:34 DEBUG SessionImpl.flushCollections(2790) - Scheduling collection removes/(re)creates/updates
2004-08-16 16:49:34 DEBUG SessionImpl.flushEverything(2266) - Flushed: 1 insertions, 0 updates, 0 deletions to 3 objects
2004-08-16 16:49:34 DEBUG SessionImpl.flushEverything(2271) - Flushed: 0 (re)creations, 0 updates, 0 removals to 2 collections
2004-08-16 16:49:34 DEBUG Printer.toString(75) - listing entities:
2004-08-16 16:49:34 DEBUG Printer.toString(82) - com.aol.ic.art.data.vo.RequestVO{comments=Update Testing, products=uninitialized, fulfillmentRoomNumber=nextApproverRoleDn, customerDn=customerDn, requ
estType=SOFTWARE, lastApproverDn=lastApproverDn, fulfillmentBuildingDn=200200, state=OPEN, ticketNumber=ticketNumber, nextApproverRoleDn=fulfillmentBuildingDn, id=10, requestorDn=requestorDn}
2004-08-16 16:49:34 DEBUG Printer.toString(82) - com.aol.ic.art.data.vo.RequestStatusVO{requestVO=RequestVO#20, state=PENDING_APPROVAL, dateStateAttained=16 August 2004 16:49:34, id=11}
2004-08-16 16:49:34 DEBUG Printer.toString(82) - com.aol.ic.art.data.vo.RequestVO{comments=comments, products=uninitialized, fulfillmentRoomNumber=nextApproverRoleDn, customerDn=customerDn, requestTyp
e=SOFTWARE, lastApproverDn=lastApproverDn, fulfillmentBuildingDn=200200, state=OPEN, ticketNumber=ticketNumber, nextApproverRoleDn=fulfillmentBuildingDn, id=20, requestorDn=requestorDn}
2004-08-16 16:49:34 DEBUG SessionImpl.execute(2355) - executing flush
2004-08-16 16:49:34 DEBUG EntityPersister.insert(453) - Inserting entity: [com.aol.ic.art.data.vo.RequestStatusVO#11]
2004-08-16 16:49:34 DEBUG BatcherImpl.logOpenPreparedStatement(196) - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-08-16 16:49:34 DEBUG BatcherImpl.getPreparedStatement(237) - insert into REQUEST_STATE (REQUESTID, STATE, DATE_STATE_ATTAINED, ID) values (?, ?, ?, ?)
Hibernate: insert into REQUEST_STATE (REQUESTID, STATE, DATE_STATE_ATTAINED, ID) values (?, ?, ?, ?)
2004-08-16 16:49:34 DEBUG BatcherImpl.getPreparedStatement(241) - preparing statement
2004-08-16 16:49:34 DEBUG EntityPersister.dehydrate(388) - Dehydrating entity: [com.aol.ic.art.data.vo.RequestStatusVO#11]
2004-08-16 16:49:34 DEBUG NullableType.nullSafeSet(46) - binding '20' to parameter: 1
2004-08-16 16:49:34 DEBUG NullableType.nullSafeSet(46) - binding 'PENDING_APPROVAL' to parameter: 2
2004-08-16 16:49:34 DEBUG NullableType.nullSafeSet(46) - binding '16 August 2004 16:49:34' to parameter: 3
2004-08-16 16:49:34 DEBUG NullableType.nullSafeSet(46) - binding '11' to parameter: 4
2004-08-16 16:49:34 DEBUG BatcherImpl.logClosePreparedStatement(203) - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-08-16 16:49:34 DEBUG BatcherImpl.closePreparedStatement(261) - closing statement
2004-08-16 16:49:34 DEBUG SessionImpl.postFlush(2820) - post flush
2004-08-16 16:49:34 DEBUG SessionImpl.afterTransactionCompletion(585) - transaction completion
2004-08-16 16:49:34 INFO TestRequestDAOUtils.testCreateRequestStatus(?) - After creating requestStatusVO
2004-08-16 16:49:34 INFO TestRequestDAOUtils.testCreateRequestStatus(?) - Saving RequestStatusVO
2004-08-16 16:49:34 INFO TestRequestDAOUtils.testFindAll(?) - In testFindAll method