王朝网络
分享
 
 
 

更改osworkflow支持hibernate3

王朝java/jsp·作者佚名  2006-02-01
宽屏版  字体: |||超大  

问题分析: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();

}

方法创建出来的。

对于外界提供sessionfactory和session是通过package org.springframework.orm.hibernate3.support. HibernateDaoSupport里提供出来。

包括主要的getSessionFactory,getSession,template相关,closesession等。

getting the following exception:

org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed

i have a many-to-many mapping table

have tried out lazy="false" which gives this exception.

lazy="true" also doesnt works

解决办法:

将osworkflow和propertyset源码中的包下的hbm.xml加上lazy=”false”即可。

但是,还没有考虑好如果改成默认的true,如何做才可以做到成功不让出现此错误!

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有