国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

更改osworkflow讓其支持hibernate3

2019-11-18 12:57:18
字體:
來源:轉載
供稿:網友

  問題分析:
  
  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
  
  通過跟蹤代碼可以發(fā)現,在創(chuàng)建sessionfactory是在org.springframework.orm.hibernate3.LocalSessionFactoryBean中的  protected SessionFactory newSessionFactory(Configuration config) throws HibernateException {
  
  return config.buildSessionFactory();
  
  }
  
  方法創(chuàng)建出來的。
  
  對于外界提供sessionfactor

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 仪征市| 余庆县| 宁夏| 蕲春县| 平湖市| 金坛市| 邓州市| 靖边县| 临夏县| 兴化市| 永嘉县| 凤山市| 普陀区| 汝南县| 宣威市| 苏尼特左旗| 和政县| 双峰县| 马公市| 平顺县| 铜陵市| 陈巴尔虎旗| 犍为县| 鹿邑县| 武邑县| 临泉县| 仲巴县| 桃园县| 湘西| 襄垣县| 铁力市| 淳安县| 罗定市| 海丰县| 霍林郭勒市| 佛学| 新田县| 苗栗县| 皋兰县| 鹿泉市| 富川|