IBatis, XML file

Posted on 2006-11-20
Last Modified: 2012-06-27
Hi experts,
I am using Ibatis for Database management and VS:2005(ASP.Net 2.0) tool for an app.
when I run my project, there is error from sqlMap.config file:

- The error occurred while Validate SqlMap config.
- The error occurred in <sqlMap embedded="SqlMaps.ProductGroup.xml, DTWR.MarketingCampaign.Data"

Here are files from my project

1. project User Interface: 2 textboxes, 1 button--save items into product group
SqlMap.config file

<?xml version="1.0" encoding="utf-8"?>

    <setting validateSqlMap="true"/>

  <providers embedded="DTWR.MarketingCampaign.Data.providers.config, DTWR.MarketingCampaign.Data"/>

  <!-- Database connection information -->
    <provider name="sqlServer2.0"/>
    <dataSource name="test" connectionString="Data Source=(local);Initial Catalog=test;User ID=sa;Password=01"/>

    <sqlMap embedded="SqlMaps.ProductGroup.xml, DTWR.MarketingCampaign.Data" />


2. project.Domain: productGroup.cs

namespace DTWR.MarketingCampaign.Domain
    public class ProductGroup
        public string groupID;
        public string productID;

        public string GroupID
            get { return groupID; }
            set { groupID = value; }

        public string ProductID
            get { return productID; }
            set { productID = value; }

3. Project Data: include one .xml file and one .cs file
<?xml version="1.0" encoding="utf-8" ?>
    <typeAlias alias="ProductGroup" type="DTWR.MarketingCampaign.Domain.ProductGroup, DTWR.MarketingCampaign.Domain" />
  <parameterMap id="ProductSelection" class="ProductGroup">
    <parameter column="Selection_ID" property="groupID"/>
    <parameter column="Product_ID" property="productID"/>

  <statement id="insertProduct" parameterMap="ProductSelection">
    insert into Product_Selection (Selection_ID, Product_ID) values (#groupID#,#productID#);


using System;
using System.Collections.Generic;
using System.Text;
using DTWR.MarketingCampaign.Domain;
using DTWR.MarketingCampaign.Data;
using IBatisNet.DataMapper;

namespace DTWR.MarketingCampaign.Data.ProductManagementService
    public class ProductSelection
        public static ProductGroup insertProduct(DTWR.MarketingCampaign.Domain.ProductGroup pg)
            return Mapper.Instance().Insert("insertProduct", pg) as ProductGroup;

4. Project Logic:using System;
using System.Collections.Generic;
using System.Text;
using DTWR.MarketingCampaign.Domain;
using DTWR.MarketingCampaign.Data;
using DTWR.MarketingCampaign.Data.ProductManagementService;

namespace DTWR.MarketingCampaign.BusinessLogic
    public class SaveProduct
        public SaveProduct(string gID, string pID)
            DTWR.MarketingCampaign.Domain.ProductGroup newobj = new ProductGroup();
            newobj.groupID = gID;
            newobj.productID = pID;

Question by:dtwoway
  • 2

Expert Comment

ID: 17992477
Please try
    <sqlMap embedded="Maps.productGroup.xml, DTWR.MarketingCampaign.Data" />

instead of your
    <sqlMap embedded="SqlMaps.ProductGroup.xml, DTWR.MarketingCampaign.Data" />

in SqlMap.config file

Author Comment

ID: 17997160
Hi vihieu,

I tried your comment, it didn't work.

Author Comment

ID: 17997752
Ok,  I already fix the problem. The problem came from .XML file insert into statement. I use  
<generate table="Product_Selection" /> instead of  insert into Product_Selection (Selection_ID, Product_ID) values (#groupID#,#productID#). It works.  But I don't know when i should use insert into statement except "generate table" statement.

Accepted Solution

Computer101 earned 0 total points
ID: 18189456
PAQed with points refunded (250)

EE Admin

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now