Raible's Wiki
Raible Designs AppFuseHomepage- Korean - Chinese - Italian - Japanese QuickStart Guide User Guide Tutorials Other ApplicationsStruts ResumeSecurity Example Struts Menu
Set your name in
UserPreferences
Referenced by
JSPWiki v2.2.33
Hide Menu |
This is version 299.
It is not the current version, and thus it cannot be edited. this mailing list thread.
<property name="sessionFactory"><ref local="sessionFactory"/></property> So to access the Hibernate session from within your DAO, place a method like this in your DAO: Session session = SessionFactoryUtils.getSession(getSessionFactory(), false);
private void createApplicationContext() { if (ctx == null) { ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servlet.getServletContext()); } } public net.sf.hibernate.Session getCurrentHibernateSession() { createApplicationContext(); SessionFactory sessionFactory = (SessionFactory)ctx.getBean("sessionFactory"); SessionHolder sessionHolder = (SessionHolder)TransactionSynchronizationManager.getResource(sessionFactory); net.sf.hibernate.Session currentSession = null; Transaction currentTransaction = null; if (sessionHolder!=null) { currentSession = sessionHolder.getSession(); currentTransaction = sessionHolder.getTransaction(); } return currentSession; } Attachments:
|