IBatisNet :有没有熟悉最新版本的高手啊?
有没有谁用过将数据源配置独立出来的?帮我解答点问题!
我的配置文件dao.config
<?xml version="1.0" encoding="utf-8"?>
<daoConfig
xmlns="http://ibatis.apache.org/dataAccess"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<providers resource="providers.config"/>
<context id="AccessMapDao" default="true">
<database>
<provider name="OleDb2.0" />
<dataSource name="Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\NEWS\NEWS\App_Data\demo.mdb;" />
</database>
<daoSessionHandler id="SqlMap">
<property name="resource" value="sqlMap.config"/>
</daoSessionHandler>
<daoFactory>
<dao
interface="YTO.Intranet.News.IDAL.IMajorNewsDao, NEWS"
implementation="YTO.Intranet.News.DAL.MajorNewsDao, NEWS"/>
</daoFactory>
</context>
</daoConfig>
我的配置文件sqlMap.comfig
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<properties resource="providers.config"/>
<properties embedded="dao.config, NEWS"/>
<settings>
<setting useStatementNamespaces="true"/>
</settings>
<sqlMaps>
<sqlMap resource="NEWS/sqlMaps/MajorNews.config"/>
</sqlMaps>
</sqlMapConfig>
我用了一个BLL层来作为对数据库的操作
public class MajorNewsBiz
{
private IDaoManager daoManager;
private IMajorNewsDao majorNewsDao;
public MajorNewsBiz()
{
daoManager = ServiceConfig.GetInstance().DaoManager;
majorNewsDao = daoManager.GetDao(typeof(IMajorNewsDao)) as IMajorNewsDao;
}
}
直接运行的话报configurationException错:
- The error occurred while configure DaoSessionHandler.
- The error occurred in <property name="resource" value="sqlMap.config" xmlns="http://ibatis.apache.org/dataAccess" />.
- Check the IBatisNet.DataAccess.DaoSessionHandlers.SqlMapDaoSessionHandler.
然后我把dao.config中的
<daoSessionHandler id="SqlMap">
<property name="resource" value="sqlMap.config"/>
</daoSessionHandler>
给注释掉了之后运行!
报DataAccessException错误:
DaoProxy : unable to intercept method name 'FindAllMajorNews', cause : 无法将类型为“IBatisNet.DataAccess.DaoSessionHandlers.SimpleDaoSession”的对象强制转换为类型“IBatisNet.DataAccess.DaoSessionHandlers.SqlMapDaoSession”。
这个到底是什么原因啊!
我下载了价格Demo看了下,一样的配置啊,没什么问题啊!