Hibernate SessionFactory:如何在Tomcat中配置JNDI?
这就是会话工厂的获取方式:
protected SessionFactory getSessionFactory() { try { return (SessionFactory) new InitialContext() .lookup("SessionFactory"); } catch (Exception e) { } }
请提供一个简单的解决方案,让Tomcat6能够获取SessionFactory 通过 Java 代码中的简单 jndi 查找。 Tomcat这边的什么文件应该写什么?
that's how the session factory should be gotten:
protected SessionFactory getSessionFactory() { try { return (SessionFactory) new InitialContext() .lookup("SessionFactory"); } catch (Exception e) { } }
Please provide a simple solution for Tomcat6 to be able to get SessionFactory
thru simple jndi lookup in Java code.
What should be written in what file on the side of Tomcat ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个链接
但是
其他答案也欢迎。
Here's a link
http://community.jboss.org/wiki/UsingJNDI-boundSessionFactorywithTomcat41
But other answers are welcome as well.
Tomcat 文档说:
Hibernate 文档说相同:
所以你需要像这样定制 SessionFactory :
Tomcat documentation says:
And Hibernate documentation says the same:
So you need to make custom
SessionFactory
like that: