Hello there Farrukh, thank you :) That was really the error, I've added the .xsd files to VS 2005 and now I get Intellisense. :)

thank you
Anderson Fortaleza

On 8/18/06, Farrukh Nizami <[EMAIL PROTECTED]> wrote:

Hi, I am also a newbie to IBatis but I guess you are getting this error due to a problem in map file Customer.xml. You are missing <resultMaps> tag. It should be like this:

 

<?xml version=" 1.0" encoding="utf-8" ?>
<sqlMap namespace="Test"
  xmlns=" http://ibatis.apache.org/mapping "
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
  <alias>
    <typeAlias alias="Customer" type=" iBatisNorthwind.Customer" />
  </alias>
<resultMaps>

  <resultMap id="result" class="System.Collections.IList">
    <result property="CustomerID" column="CustomerID" />
    <result property="CompanyName" column="CompanyName" />
    <result property="ContactName" column="ContactName" />
    <result property="ContactTitle" column="ContactTitle" />
    <result property="Address" column="Address" />
    <result property="City" column="City" />
    <result property="Region" column="Region" />
    <result property="PostalCode" column="PostalCode" />
    <result property="Country" column="Country" />
    <result property="Phone" column="Phone" />
    <result property="Fax" column="Fax" />
  </resultMap>
</resultMaps>

  <statements>
    <select id="customersByCountry" param="System.String" resultMap="result">
      <![CDATA[ SELECT * FROM Customers WHERE Country = #Country# ]]>
    </select>
  </statements>
</sqlMap>

Give it a try.

Thanks & Regards
Farrukh Nizami


From: Anderson Forteleza [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 18, 2006 4:21 PM
To: [email protected]
Subject: Help: This SQL map does not contain an ResultMap named...

 

Hello there ! I'm a newbie to iBatis and I'm excited by the possibilities it gives me.


I'm trying to setup a basic test application where I can get values from the Northwind database, I'm using SQL Server Express but when I try to run the program I get the following error:

"This SQL map does not contain an ResultMap named Test.result"

IuseStatementNamespaces is set to false, but this error is showing up anyway, here's some information:

sqlMap.config
==========
<?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="Resources/properties.config" />

  <settings>
    <setting useStatementNamespaces="false" />
  </settings>

  <providers resource="Resources/providers.config" />

  <!-- Database connection information -->
  <database>
    <provider name="sqlServer2.0 " />
    <dataSource name="Northwind" connectionString="Data Source=DARKSTAR\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True" />
  </database>

  <sqlMaps>
    <sqlMap resource="Resources/Maps/Customers.xml" />
  </sqlMaps>
</sqlMapConfig>

I'm using the providers.config provided with iBatis DataMapper 1.5.1 distribution.

Here's my DataMapper file:

Customers.xml
===========
<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="Test"
  xmlns=" http://ibatis.apache.org/mapping "
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
  <alias>
    <typeAlias alias="Customer" type=" iBatisNorthwind.Customer" />
  </alias>

  <resultMap id="result" class="System.Collections.IList">
    <result property="CustomerID" column="CustomerID" />
    <result property="CompanyName" column="CompanyName" />
    <result property="ContactName" column="ContactName" />
    <result property="ContactTitle" column="ContactTitle" />
    <result property="Address" column="Address" />
    <result property="City" column="City" />
    <result property="Region" column="Region" />
    <result property="PostalCode" column="PostalCode" />
    <result property="Country" column="Country" />
    <result property="Phone" column="Phone" />
    <result property="Fax" column="Fax" />
  </resultMap>

  <statements>
    <select id="customersByCountry" param="System.String" resultMap="result">
      <![CDATA[ SELECT * FROM Customers WHERE Country = #Country# ]]>
    </select>
  </statements>
</sqlMap>

I've tryed to use the full name Test.result but to no avail. What is interesting is that I see many people instanciating the singleton using this sintax:

SqlMapper mapper = Mapper.Instance();

But when I try to do that VS 2005 gives me a cast error message:

Error    119    Cannot implicitly convert type 'IBatisNet.DataMapper.ISqlMapper' to 'IBatisNet.DataMapper.SqlMapper '. An explicit conversion exists (are you missing a cast?)    D:\Projects\iBatisNorthwind\Program.cs    13    32    iBatisNorthwind

Wich is weird because SqlMapper implements ISqlMapper. I'm typecasting then:

SqlMapper mapper = (SqlMapper)Mapper.Instance();

Here's the complete error message:
- The error occurred while loading SqlMap.
- loading select tag
- The error occurred in <sqlMap resource="Resources/Maps/Customers.xml" xmlns=" http://ibatis.apache.org/dataMapper" />.
- Check the Test.customersByCountry. ---> IBatisNet.DataMapper.Exceptions.DataMapperException : This SQL map does not contain an ResultMap named Test.result
... callstack information...

I'm testing iBatis to use here in the school where I work, any help would be appreciated :)

thank you
Anderson Fortaleza


Reply via email to