Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hi,
I am trying to use application transaction between 2 clases and trying to insert in the second one but apparently because I did session.save in the first class, and generate an Id, when I perform a lock and saveOrUpdate just try to update and nothign happen since I never flush or commit in the first class, its my approach wrong? should I use instead a session transaction as indicated in HiA?
class 1
{..........
session1.save(Item) //because I need its Id
request.getSession().setAttribute("itemLong",item);
session1.close(). // without commit or flush() because user MUST use the other class
.....
}
class 2
{ ..........
Item item = (Item)request.getSession().getAttribute("itemLong");
session2.lockl(item,LockMode.NONE);
....... bussines process..
session.save(item);
tx.commit();
session.close();
request.getSession().removeAttribute("itemLong");
...
}
Debug:
2004-12-28 12:16:40,247 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session
2004-12-28 12:16:40,247 DEBUG [net.sf.hibernate.transaction.JDBCTransaction] begin
2004-12-28 12:16:40,390 DEBUG [net.sf.hibernate.transaction.JDBCTransaction] current autocommit status:false
2004-12-28 12:16:40,390 DEBUG [net.sf.hibernate.engine.Cascades] id unsaved-value strategy NULL
2004-12-28 12:16:40,390 DEBUG [net.sf.hibernate.impl.SessionImpl] reassociating transient instance: [Item#706782]
2004-12-28 12:16:40,402 DEBUG [net.sf.hibernate.engine.Cascades] cascading to lock()
2004-12-28 12:16:40,402 DEBUG [net.sf.hibernate.engine.Cascades] id unsaved-value strategy NULL
2004-12-28 12:16:40,402 DEBUG [net.sf.hibernate.engine.Cascades] done processing cascades for:Item
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.impl.SessionImpl] object already associated with session
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.transaction.JDBCTransaction] commit
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.impl.SessionImpl] flushing session
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.engine.Cascades] processing cascades for: Item
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.engine.Cascades] cascading to saveOrUpdate()
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.impl.SessionImpl] saveOrUpdate() persistent instance
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.engine.Cascades] done processing cascades for: Item
2004-12-28 12:16:49,638 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushing entities and processing referenced collections
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.SessionImpl] Processing unreferenced collections
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.SessionImpl] Scheduling collection removes/(re)creates/updates
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.Printer] listing entities:
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.Printer] Item{estAmtCurrency=null, euPd=null, undbOrigPubDate=null, id=706782, noticeType=rei, euPr=null, undbPubDate=null, euRp=null, editDate=28 December 2004 12:16:02, submissionAddress=Contact#5543, euOj=null, needsUndbP=null, euDd=null, locality=lima limon, euDr=null, euTy=null, euNc=null, estAmount=null, draft=null, euDs=null, methodId=1, purchaserId=null, euRn=null, fundingAgency=null, refNo=null, impAgency=null, noticeTitles=null, bidDocsP=false, publishNotice=null, noticeItems=null, noticeHistory=null, euNd=null, noticeTexts=null, noticeRegions=null, euAa=null, editUser=727656, status=draft, noticeFiles=null, euOl=null, bidNo=123, country=al, projectId=null, euAc=null, statusDate=28 December 2004 12:16:02, euHd=null, statusUser=727656, dirty=1, parent=Buyer#1012, euTd=I, bidDeadlineDate=02 February 2005 14:30:02}
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.SessionImpl] executing flush
2004-12-28 12:16:49,639 DEBUG [net.sf.hibernate.impl.SessionImpl] post flush
2004-12-28 12:16:49,668 DEBUG [net.sf.hibernate.impl.SessionImpl] transaction completion
2004-12-28 12:16:51,021 DEBUG [net.sf.hibernate.impl.SessionImpl] running Session.finalize()
2004-12-28 12:16:52,105 DEBUG [net.sf.hibernate.impl.SessionImpl] closing session
|