网站首页
JSP空间
动态资讯
开源项目
技术文档
资源下载
J2EE资源
客户论坛
在线支付
 
  技术文档>>JAVA>>新手入门>>基础入门>查看文档  
  更改osworkflow让其支持hibernate3     
  文章作者:未知  文章来源:水木森林  
  查看:104次  录入:管理员--2007-11-17  
 
  问题分析:
  
  osworkflow2.7.0支持 hibernate2.1.8
  
  问题一:propertyset找不到对应的源码。在opensymphony上下载到的代码与osworkflow中包含的propertyset包不一致。
  
  osworkflow2.7.0自带的为propertyset-1.3-21apr04.jar。而实际在主站中下载到的为propertyset1.3.jar
  
  其中在propertyset-1.3-21apr04.jar(没有找到对应的源码)包中的
  
  defaulthibernateconfigurationprovider包含成员变量和方法:
  
  private net.sf.hibernate.cfg.configuration configuration;
  
  private com.opensymphony.module.propertyset.hibernate.hibernatepropertysetdao propertysetdao;
  
  private net.sf.hibernate.sessionfactory sessionfactory;
  
  static synthetic java.lang.class class$com$opensymphony$module$propertyset$hibernate$propertysetitemimpl;
  
  方法:
  
  无参的构造函数
  
  public void setconfiguration(configuration configuration);
  
  public configuration getconfiguration();
  
  public hibernatepropertysetdao getpropertysetdao();
  
  public void setsessionfactory(sessionfactory sessionfactory);
  
  public void setupconfiguration(map configurationproperties);
  
  static synthetic class class$(string x0);
  
  而在opensymphony上下载到的defaulthibernateconfigurationprovider的代码为:
  
  private configuration configuration;
  
  private hibernatepropertysetdao propertysetdao;
  
  private sessionfactory sessionfactory;
  
  //~ methods ////////////////////////////////////////////////////////////////
  
  public configuration getconfiguration() {
  
  return configuration;
  
  }
  
  public hibernatepropertysetdao getpropertysetdao() {
  
  if (propertysetdao == null) {
  
  propertysetdao = new hibernatepropertysetdaoimpl(sessionfactory);
  
  }
  
  return propertysetdao;
  
  }
  
  public void setupconfiguration(map configurationproperties) {
  
  // loaded hibernate config
  
  try {
  
  configuration = new configuration().addclass(propertysetitem.class);
  
  iterator itr = configurationproperties.keyset().iterator();
  
  while (itr.hasnext()) {
  
  string key = (string) itr.next();
  
  if (key.startswith("hibernate")) {
  
  configuration.setproperty(key, (string) configurationproperties.get(key));
  
  }
  
  }
  
  this.sessionfactory = configuration.buildsessionfactory();
  
  } catch (hibernateexception e) {
  
  }
  
  }
  
  另:
  
  类名与xml名的变化:
  
  propertysetitem与propertysetitem.hbm.xml
  
  在原有jar包中为propertysetitemimpl和propertysetitemimpl.hbm.xml
  
  解决办法:
  
  问题二:hibernate包名的变化分析
  
  hibernate2中包含expression包,而在hibernate3中则没有了。在hibernate3中多出来一个criterion包。
  
  hibernate就在3.0的时候换上antlr来解释hql,使hql的语法获得了加强。
  
  解决办法:
  
  问题三:osworkflow所需要的必要的jar包,我在更改osworkflow源码过程中,把webwork这部分去掉了,已解决,保证除了hibernate以外的其他部分可以正常便宜通过。尽量缩减需要更改的范围。然后把原先的jar解压,把更改的类重新覆盖对应的部分(只覆盖更改的部分),然后重新打包即可。这部分已解决!通过从cvs上获取最新代码可以解决。
  
  代码更改部分:
  
  propertyset更改方案:
  
  propertyset从cvs上获取最新代码,更改对应hibernate包内的所有引入的hibernate2改为hibernate3包。
  
  对于osworkflow从cvs上下载的代码更改hibernateworkflowstore
  
  添加两个方法
  
  // add find method for this class by yunguang
  
  public list find(string querystring) throws storeexception {
  
  query queryobject = session.createquery(querystring);
  
  return queryobject.list();
  
  }
  
  public list find(string querystring, object value) throws storeexception {
  
  query queryobject = session.createquery(querystring);
  
  queryobject.setparameter(0, value);
  
  return queryobject.list();
  
  }
  
  然后在此类中其他涉及到find方法的地方改到刚新加的find方法上,而hibernate2的find方法会多个type类型的参数,去掉即可。
  
  包名更改好,其他就没什么太大变动的地方,根据eclipse的错误提示一点一点改就可以了。
  
  问题解决备案:
  
  解决hibernate3的“system property org.xml.sax.driver not specified”异常错误。
  
  i got a saxexception("system property org.xml.sax.driver not specified")
  when i tried to run the schemaexporttask.
  
  i solved the problem by installing jaxp. i then had to make sure that
  all the jars (dom.jar sax.jar xalan.jar xercesimpl.jar xsltc.jar)
  were in lib/endorsed under both my jdk installation root and my jre
  installation root.
  
  hope that helps someone,
  bobby
  
  so,in conclusion,in order to make it works as fine as you expected,you can do as the following ways to get an xmlreader:
  (1)
  xmlreader parser=xmlreaderfactory.createxmlreader(string classname);
  (2)
  system.setproperty("org.xml.sax.driver","org.apache.xerces.parsers.saxparser");
  xmlreader parser=xmlreaderfactory.createxmlreader();
  (3)
  system.setproperty("org.xml.sax.parser","org.apache.xerces.parsers.saxparser");
  xmlreader parser=xmlreaderfactory.createxmlreader();
  (4) more directly
  xmlreader parser=new org.apache.xerces.parsers.saxparser();
  
  note that:
  1) in case (3),the parser is an instance of parseradaptor,it doesn't support the feture "http://xml.org/sax/features/validation",differented from the other cases.
  2) in case (2),the class you specified should implement the interface xmlreader, in case (3),the class you specified should implement the interface saxparser.org.apache.xerces.parsers.saxparser is applicable in both case.
  
  我是采用第二种办法解决的。
  
  warn [(ehcache.config.configurator)] no configuration found. configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/d:/tools/eclipse3.1/workspace/osworkflowfromcvs/lib/optional/ehcache.jar!/ehcache-failsafe.xml
  
  error [(spi.hibernate.springhibernatefunctionalworkflowtestcase)] org.springframework.beans.factory.beancreationexception: error creating bean with name 'osworkflowconfiguration' defined in class path resource [osworkflow-spring.xml]: can't resolve reference to bean 'workflowstore' while setting property 'store'; nested exception is org.springframework.beans.factory.beancreationexception: error creating bean with name 'workflowstore' defined in class path resource [osworkflow-spring.xml]: can't resolve reference to bean 'sessionfactory' while setting property 'sessionfactory'; nested exception is org.springframework.beans.factory.beancreationexception: error creating bean with name 'sessionfactory' defined in class path resource [osworkflow-spring.xml]: initialization of bean failed; nested exception is java.lang.noclassdeffounderror: antlr/antlrexception
  
  解决办法将antlr的jar包加上就好了。
  
  解决hibernate2转移到hibernate3的
  
  error [(org.hibernate.lazyinitializationexception)] could not initialize proxy - the owning session was closed
  
  通过跟踪代码可以发现,在创建sessionfactory是在org.springframework.orm.hibernate3.localsessionfactorybean中的  protected sessionfactory newsessionfactory(configuration config) throws hibernateexception {
  
  return config.buildsessionfactory();
  
  }
  
  方法创建出来的。
  
  对于外界提供sessionfactor
 
 
上一篇: 开源框架hibernate 3 的formulas(图)    下一篇: 精通hibernate之映射继承关系八
  相关文档
加密与解密原理的一个例子 11-17
j2ee基础应用:j2ee中sql语句自动构造方法 04-22
技巧:用java语言实现对称加密实例详解 11-16
java 类中类属性和对象属性的初始化顺序 11-17
2006的年度技术和框架介绍? 11-17
数据库相关--一篇关于优化sql的文章 01-25
totalsize 属性 11-16
Java使用技巧:访问在接口中定义的常量 08-07
grails + ejb domain models 11-17
jbuilder2005创建开发文档之javadoc 11-16
实 现java 的 动 态 类 载 入 机 制 11-17
java反射技术(二) 11-17
最佳实践:勿在 servlet 中实现 singlethreadmodel 11-17
实战角度比较ejb2和ejb3的架构异同 11-17
eclipse入门使用指南及开发eclipse插件(6) 11-17
远程控制java 11-17
java learning path (一)、工具篇 11-17
如何编写安全的Java代码 04-14
type 属性 11-16
j2se 1.5新特性简介 11-16
返回首页 | 关于我们 | J网章程 | JSP空间合租 | 客服中心 | 免责声明 | 常见问题 | 参观机房
本站主机空间代理至厦门市华众网络科技有限公司
《中华人民共和国增值电信业务经营许可证》
编号:闽B2-20050079
@2005-2008福建JSP技术网 版权所有 闽ICP备05000928号
技术电话:13616026886
邮箱:admin@fjjsp.com 站长QQ,点击这里给我发消息