hibernate.cfg.xml放在classes目录下
解决方案 »
- Struts2中两个Action之间参数传递的问题!
- JFreeChart数据范围最小跨度怎么设置?
- 关于SQL连接问题
- 对一张表更新出异常了 大家帮帮忙 在线等帮助
- 为什么在action中用hibernate保存一个新对象时,不能马上得到它的id号呢??而在jsp页面里做保存操作就能得到.
- 求过滤用户注册的字符串的函数
- 《精通Struts:基于MVC的Java Web设计与开发》哪里有下载?
- jboss+eclipse+oracle怎么配置?怎么在jboss下运行servlets?
- application程序连接数据源出错,请高手赐教
- 线程问题(初学者)
- JAVA录音程序调用
- [CVS问题]请教CVS帐户的问题。
如果不做分布没必要用ejb
直接struts+hibernate不就好了?
package com.beststar.sjrkxt.ejb.sb;
public void Hello(){
try {
_RootDAO.initialize("/hibernate.cfg.xml");
} catch (HibernateException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
RootDAO中:
package com.beststar.sjrkxt.hbnt.base; public static void initialize (String configFileName) throws HibernateException {
if (null == configFileName && sessionFactoryMap.size() > 0) return;
else if (null != sessionFactoryMap.get(configFileName)) return;
else {
Configuration cfg = new Configuration();
if (null == configFileName)
cfg.configure();
else
cfg.configure(configFileName);
setSessionFactory(configFileName, cfg.buildSessionFactory());
}
}
sessionFactoryMap.put(configFileName, sessionFactory);
}
Look, this guy gets troubles. It is the Hibernate's problem.You can try this, all your hibernate classes are saved in one URL, and make a resource refered by the EJB. Inside the EJB you code JNDI look up the URL and download the class for local use. I don't think this is J2EE project if you play Hibernate.