Team,
I am beside myself on this one. I Spent all morning on it. I have not a clue
on this. I am basically trying to create a sample for testing IBastis.
-------------
sqlmap.config
--------------
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMapConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<settings>
<setting cacheModelsEnabled="true"/>
<setting useStatementNamespaces="false"/>
<setting validateSqlMap="false"/>
<setting useReflectionOptimizer="true"/>
</settings>
<database>
<provider name="sqlServer2.0"/>
<dataSource name="TestServer" connectionString="Data
Source=testdbserver;Initial Catalog=TEST257;user=user1;password=abc123;" />
</database>
<sqlMaps>
<sqlMap resource="User.xml"/>
</sqlMaps>
</sqlMapConfig>
-------------
User.xml
-------------
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="User" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ibatis.apache.org/mapping">
<alias>
<typeAlias alias="User" type="QuickStart.Types.User, QuickStart.Types"/>
</alias>
<resultMaps>
<resultMap id="UserResult" class="User">
<result property="Id" column="userid"/>
</resultMap>
</resultMaps>
<statements>
<select id="GetUser" resultMap="UserResult" parameterClass="String">
SELECT
userid
FROM
dbo.Users
<dynamic prepend="WHERE">
<isParameterPresent>
userid = #value#
</isParameterPresent>
</dynamic>
</select>
</statements>
</sqlMap>
------------
mapper.cs
------------
using System;
using IBatisNet.Common.Utilities;
using IBatisNet.DataMapper;
using IBatisNet.DataMapper.Configuration;
namespace QuickStart.DataAccess
{
public class Mapper
{
private static volatile ISqlMapper _mapper = null;
private Mapper() { }
protected static void Configure(object obj)
{
_mapper = null;
}
public static ISqlMapper Get()
{
return Instance();
}
protected static void InitMapper()
{
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
_mapper = builder.ConfigureAndWatch(handler);
}
public static ISqlMapper Instance()
{
if (_mapper == null)
{
lock (typeof(SqlMapper))
{
if (_mapper == null)
{
InitMapper();
}
}
}
return _mapper;
}
}
}
-----------
mapperFixture
-----------
[Test]
public void InstanceTest()
{
ISqlMapper mapper = Mapper.Instance();
}
I am simply trying to test that I can an instance and all the config loads fine
but instead I get the following:
Message:
- The error occurred while Validate SqlMap config.
Type: IBatisNet.Common.Exceptions.ConfigurationException
Source: IBatisNet.DataMapper
TargetSite: IBatisNet.DataMapper.ISqlMapper Build(System.Xml.XmlDocument,
IBatisNet.Common.DataSource, Boolean, Boolean)
HelpLink: null
Stack: at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao)
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(String
resource, ConfigureHandler configureDelegate)
at
IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ConfigureAndWatch(ConfigureHandler
configureDelegate)
at QuickStart.DataAccess.Mapper.InitMapper() in
C:\Development\iBATIS\QuickStart\Source\QuickStart.DataAccess\Mapper.cs:line 31
at QuickStart.DataAccess.Mapper.Instance() in
C:\Development\iBATIS\QuickStart\Source\QuickStart.DataAccess\Mapper.cs:line 43
at QuickStart.DataAccess.Test.MapperFixture.InstanceTest() in
C:\Development\iBATIS\QuickStart\Test\QuickStart.DataAccess.Test\MapperFixture.cs:line
17
The innerr exception is :
Message: Object reference not set to an instance of an object.
Type: System.NullReferenceException
Source: IBatisNet.DataMapper
TargetSite: Void ParseGlobalProperties()
HelpLink: null
Stack: at
IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.ParseGlobalProperties()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize()
at IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao)
Any help would be greatly appreciated.
_________________________________________________________________
Recharge--play some free games. Win cool prizes too!
http://club.live.com/home.aspx?icid=CLUB_wlmailtextlink