Hi Martin, I was hoping that you would reply, as ur replies are extremely precise and I like it.
However, I did indeed search before, but I couldn't really get a concrete answer. All the bits and pieces which are present in other answers didn't really solve my case. If I don't put the current_session_context_class I get this exception: Whoa!! WTH just happened?
My code runs fine again. I don't really understand this. Believe me, I did try this, but it was giving me an exception :
No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
I just removed the line: current_session_context_class and it started to work . Incidentally also removed,
hibernate.transaction.factory_class=org.hibernate. transaction.JDBCTransactionFactory
Anyways, I am still not sure, why it wasn not working earlier, and why its working now, I dont think my AOP configs. were incorrect as I have not changed them. Anyways, thanks Martin. Now, that the session has been retrieved and I see the 2 statements :open and close session on my logs, so it seems that I dnt have to close any session or do any more session related manipulations, which is great. Just to pick your brain, if you have some more time, do you see any more issues with my configurations? Agreed on the pooling size thing. This is just a POC.
Just for my reference,
Code:
[21/05/12 07:26:05:005 SGT] DEBUG support.HandlerMethodInvoker: Invoking request handler method: public java.lang.String com.spring.controller.EmployeeController.displayHomePage(long,org.springframework.ui.ModelMap)
[21/05/12 07:26:05:005 SGT] DEBUG hibernate3.HibernateTransactionManager: Creating new transaction with name [com.service.EmployeeService.getEmployeeById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT[21/05/12 07:26:05:005 SGT] DEBUG impl.SessionImpl: opened session at timestamp: 13375995652
[21/05/12 07:26:05:005 SGT] DEBUG hibernate3.HibernateTransactionManager: Opened new Session [org.hibernate.impl.SessionImpl@e6529c] for Hibernate transaction[21/05/12 07:26:05:005 SGT] DEBUG hibernate3.HibernateTransactionManager: Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@e6529c]
[21/05/12 07:26:05:005 SGT] DEBUG transaction.JDBCTransaction: begin
[21/05/12 07:26:05:005 SGT] DEBUG jdbc.ConnectionManager: opening JDBC connection
[21/05/12 07:26:05:005 SGT] DEBUG transaction.JDBCTransaction: current autocommit status: true
[21/05/12 07:26:05:005 SGT] DEBUG transaction.JDBCTransaction: disabling autocommit
[21/05/12 07:26:05:005 SGT] DEBUG hibernate3.HibernateTransactionManager: Exposing Hibernate transaction as JDBC transaction [jdbc:oracle:thin:@*, UserName=*, Oracle JDBC driver]
[21/05/12 07:26:05:005 SGT] DEBUG loader.Loader: loading entity: [com.spring.model.Employee#92179046]
[21/05/12 07:26:05:005 SGT] DEBUG jdbc.AbstractBatcher: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[21/05/12 07:26:05:005 SGT] DEBUG hibernate.SQL: select employee0_.empId as empId0_0_, employee0_.version as version0_0_, employee0_.firstname as firstname0_0_, employee0_.lastname as lastname0_0_, employee0_.emailid as emailid0_0_, employee0_.filedata as filedata0_0_, employee0_.fileName as fileName0_0_, employee0_.fileContentType as fileCont8_0_0_ from employee employee0_ where employee0_.empId=?
[21/05/12 07:26:05:005 SGT] DEBUG jdbc.AbstractBatcher: about to open ResultSet (open ResultSets: 0, globally: 0)
[21/05/12 07:26:05:005 SGT] DEBUG loader.Loader: result row: EntityKey[com.spring.model.Employee#92179046]
[21/05/12 07:26:05:005 SGT] DEBUG jdbc.AbstractBatcher: about to close ResultSet (open ResultSets: 1, globally: 1)
[21/05/12 07:26:05:005 SGT] DEBUG jdbc.AbstractBatcher: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[21/05/12 07:26:05:005 SGT] DEBUG engine.TwoPhaseLoad: resolving associations for [com.spring.model.Employee#92179046]
[21/05/12 07:26:05:005 SGT] DEBUG engine.TwoPhaseLoad: done materializing entity [com.spring.model.Employee#92179046]
[21/05/12 07:26:05:005 SGT] DEBUG engine.StatefulPersistenceContext: initializing non-lazy collections
[21/05/12 07:26:05:005 SGT] DEBUG loader.Loader: done entity load
[21/05/12 07:26:05:005 SGT] DEBUG hibernate3.HibernateTransactionManager: Initiating transaction commit
[21/05/12 07:26:05:005 SGT] DEBUG hibernate3.HibernateTransactionManager: Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@e6529c]
[21/05/12 07:26:05:005 SGT] DEBUG transaction.JDBCTransaction: commit
[21/05/12 07:26:05:005 SGT] DEBUG def.AbstractFlushingEventListener: processing flush-time cascades
[21/05/12 07:26:05:005 SGT] DEBUG def.AbstractFlushingEventListener: dirty checking collections
[21/05/12 07:26:05:005 SGT] DEBUG def.AbstractFlushingEventListener: Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
[21/05/12 07:26:05:005 SGT] DEBUG def.AbstractFlushingEventListener: Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
[21/05/12 07:26:05:005 SGT] DEBUG pretty.Printer: listing entities:
[21/05/12 07:26:05:005 SGT] DEBUG pretty.Printer: com.spring.model.Employee{fileContentType=application/octet-stream, email=new, fileName=null, empId=92179046, lastname=new, firstname=new, fileDataBytes=null, version=0}
[21/05/12 07:26:05:005 SGT] DEBUG transaction.JDBCTransaction: re-enabling autocommit
[21/05/12 07:26:05:005 SGT] DEBUG transaction.JDBCTransaction: committed JDBC Connection[21/05/12 07:26:05:005 SGT] DEBUG jdbc.ConnectionManager: transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
[21/05/12 07:26:05:005 SGT] DEBUG hibernate3.HibernateTransactionManager: Closing Hibernate Session [org.hibernate.impl.SessionImpl@e6529c] after transaction