You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Frank van Tour <fv...@wanadoo.nl> on 2007/10/22 21:46:13 UTC

Newbie ibatis Tutorial Error

Hi ,

 

Just started with ibatis tutorial 1.2.1. ( the .net 2.0 tutorial URL failed
to download ??).

In the singleton class ( as listed below ) I got the following error (Using
VS2005 and .Net 2.0)

 

 

Cannot implicitly convert type 'IBatisNet.DataMapper.ISqlMapper' to
'IBatisNet.DataMapper.SqlMapper'. 

An explicit conversion exists (are you missing a cast?)

 

Any clues what's going on here?

 

-Frank

 

using IBatisNet.DataMapper;

 

namespace iBatis

{

      /// <summary>

      /// Base class for Mapper objects (*Mapper). 

      /// Provides shared utility methods.

      /// </summary>

      public abstract class MapperBase

      {           

            public SqlMapper Mapper()

            {

                  return IBatisNet.DataMapper.Mapper.Instance ();

            }

      }

}

 


RE: Newbie ibatis Tutorial Error

Posted by Frank van Tour <fv...@wanadoo.nl>.
Thanks!

Could have figured this out myself :). However I didn't questioned the
tutorial code. Apparently the tutorial is not up-to-date.

Now the C# build goes well. Until when I call the test class, the following
error occurred:

IBatisNet.Common.Exceptions.ConfigurationException was unhandled
  Message="\r\n- The error occurred while loading SqlMap.\r\n- The error
occurred in <sqlMap resource=\"PersonMapper.xml\"
xmlns=\"http://ibatis.apache.org/dataMapper\" />."
  Source="IBatisNet.DataMapper"

I placed the personmapper.xml in the same directory as sqlmap.config to
avoid path errors.


The sqlmap.config is listed below
************************************************

<?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="properties.config"/>
    
  <providers resource="providers.config"/>
  
	<!-- Database connection information -->

  <database>
    <provider name="sqlServer1.1"/>
    <dataSource name="iBatisTutorial"
connectionString="${connectionString}"/> 
  </database>

  <sqlMaps>
    <sqlMap resource="PersonMapper.xml"/>
  </sqlMaps>

</sqlMapConfig>



The PersonMapper.xml is listed below:
************************************************

<?xml version="1.0" encoding="utf-8" ?> 
- <!-- 
sqlMap 
	namespace="Person" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:noNamespaceSchemaLocation="SqlMap.xsd"

  --> 
- <sqlMap namespace="Person" xmlns="http://ibatis.apache.org/dataMapper"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <!--  XML "behind" document for the People service class. 
  --> 
- <alias>
  <typeAlias alias="Person" type="iBatis.Person, iBatis" /> 
  </alias>
- <resultMaps>
- <resultMap id="SelectResult" class="Person">
  <result property="Id" column="PER_ID" /> 
  <result property="FirstName" column="PER_FIRST_NAME" /> 
  <result property="LastName" column="PER_LAST_NAME" /> 
  <result property="BirthDate" column="PER_BIRTH_DATE" /> 
  <result property="WeightInKilograms" column="PER_WEIGHT_KG" /> 
  <result property="HeightInMeters" column="PER_HEIGHT_M" /> 
  </resultMap>
  </resultMaps>
- <statements>
- <select id="Select" parameterClass="int" resultMap="SelectResult">
  select PER_ID, PER_FIRST_NAME, PER_LAST_NAME, PER_BIRTH_DATE,
PER_WEIGHT_KG, PER_HEIGHT_M from PERSON 
- <dynamic prepend="WHERE">
  <isParameterPresent>PER_ID = #value#</isParameterPresent> 
  </dynamic>
  </select>
  <insert id="Insert" parameterClass="Person" resultClass="int">insert into
PERSON (PER_ID, PER_FIRST_NAME, PER_LAST_NAME, PER_BIRTH_DATE,
PER_WEIGHT_KG, PER_HEIGHT_M) values (#Id#, #FirstName#, #LastName#,
#BirthDate#, #WeightInKilograms#, #HeightInMeters#)</insert> 
  <update id="Update" parameterClass="Person" resultClass="int">update
PERSON set PER_FIRST_NAME = #FirstName#, PER_LAST_NAME = #LastName#,
PER_BIRTH_DATE = #BirthDate#, PER_WEIGHT_KG = #WeightInKilograms#,
PER_HEIGHT_M = #HeightInMeters# where PER_ID = #Id#</update> 
  <delete id="Delete" parameterClass="int" resultClass="int">delete from
PERSON where PER_ID = #value#</delete> 
  </statements>
  </sqlMap>

************************************************

Any help is highly appreciated.

-Frank

-----Oorspronkelijk bericht-----
Van: Brian Elcock [mailto:brian.elcock@gmail.com] 
Verzonden: maandag 22 oktober 2007 22:14
Aan: user-cs@ibatis.apache.org
Onderwerp: Re: Newbie ibatis Tutorial Error

Frank.

I'm guessing that you're using a more recent version of IBatis than
was used in the tutorial. The API changed a bit back somewhere between
1.2 and 1.3, so you won't be able to run the tutorial as written if
you're using the latest version of the binaries. I can't remember the
exact details. If you want to run the tutorial as written, you'll need
to download an older version of the binaries. Otherwise, you'll need
to look at the code and adjust it per Tom's suggestions.

Regards.
Brian

On 10/22/07, Nguyen, Tom <To...@rels.info> wrote:
>
>
>
>
> As the error said, you have two choices:
>
>
>
>
>
>              public ISqlMapper Mapper()
>
>             {
>
>                   return IBatisNet.DataMapper.Mapper.Instance();
>
>             }
>
>
>
> Or:
>
>              public SqlMapper Mapper()
>
>             {
>
>                   return (IBatisNet.DataMapper.Mapper.Instance() as
> SqlMapper);
>
>             }
>
>
>
>
>
>
> Regards,
>
>
>  Tom Nguyen
>  Sr. Developer
>  tom.nguyen@rels.info
>
>
>
>  ________________________________
>
>
> From: Frank van Tour [mailto:fvantour@wanadoo.nl]
>  Sent: Monday, October 22, 2007 2:46 PM
>  To: user-cs@ibatis.apache.org
>  Subject: Newbie ibatis Tutorial Error
>
>
>
> Hi ,
>
>
>
> Just started with ibatis tutorial 1.2.1. ( the .net 2.0 tutorial URL
failed
> to download ??).
>
> In the singleton class ( as listed below ) I got the following error
(Using
> VS2005 and .Net 2.0)
>
>
>
>
>
> Cannot implicitly convert type 'IBatisNet.DataMapper.ISqlMapper' to
> 'IBatisNet.DataMapper.SqlMapper'.
>
> An explicit conversion exists (are you missing a cast?)
>
>
>
> Any clues what's going on here?
>
>
>
> -Frank
>
>
>
> using IBatisNet.DataMapper;
>
>
>
> namespace iBatis
>
> {
>
>       /// <summary>
>
>       /// Base class for Mapper objects (*Mapper).
>
>       /// Provides shared utility methods.
>
>       /// </summary>
>
>       public abstract class MapperBase
>
>       {
>
>             public SqlMapper Mapper()
>
>             {
>
>                   return IBatisNet.DataMapper.Mapper.Instance ();
>
>             }
>
>       }
>
> }
>
>
>
>  ________________________________
>
>
>
>
> This e-mail message and any files transmitted herewith, are intended
solely
> for the use of the individual(s) addressed and may contain confidential,
> proprietary or privileged information.  If you are not the addressee
> indicated in this message (or responsible for delivery of this message to
> such person) you may not review, use, disclose or distribute this message
or
> any files transmitted herewith.  If you receive this message in error,
> please contact the sender by reply e-mail and delete this message and all
> copies of it from your system.
>
>  ________________________________
>
>
>
>
>
>
>
>
>
>
>



Re: Newbie ibatis Tutorial Error

Posted by Brian Elcock <br...@gmail.com>.
Frank.

I'm guessing that you're using a more recent version of IBatis than
was used in the tutorial. The API changed a bit back somewhere between
1.2 and 1.3, so you won't be able to run the tutorial as written if
you're using the latest version of the binaries. I can't remember the
exact details. If you want to run the tutorial as written, you'll need
to download an older version of the binaries. Otherwise, you'll need
to look at the code and adjust it per Tom's suggestions.

Regards.
Brian

On 10/22/07, Nguyen, Tom <To...@rels.info> wrote:
>
>
>
>
> As the error said, you have two choices:
>
>
>
>
>
>              public ISqlMapper Mapper()
>
>             {
>
>                   return IBatisNet.DataMapper.Mapper.Instance();
>
>             }
>
>
>
> Or:
>
>              public SqlMapper Mapper()
>
>             {
>
>                   return (IBatisNet.DataMapper.Mapper.Instance() as
> SqlMapper);
>
>             }
>
>
>
>
>
>
> Regards,
>
>
>  Tom Nguyen
>  Sr. Developer
>  tom.nguyen@rels.info
>
>
>
>  ________________________________
>
>
> From: Frank van Tour [mailto:fvantour@wanadoo.nl]
>  Sent: Monday, October 22, 2007 2:46 PM
>  To: user-cs@ibatis.apache.org
>  Subject: Newbie ibatis Tutorial Error
>
>
>
> Hi ,
>
>
>
> Just started with ibatis tutorial 1.2.1. ( the .net 2.0 tutorial URL failed
> to download ??).
>
> In the singleton class ( as listed below ) I got the following error (Using
> VS2005 and .Net 2.0)
>
>
>
>
>
> Cannot implicitly convert type 'IBatisNet.DataMapper.ISqlMapper' to
> 'IBatisNet.DataMapper.SqlMapper'.
>
> An explicit conversion exists (are you missing a cast?)
>
>
>
> Any clues what's going on here?
>
>
>
> -Frank
>
>
>
> using IBatisNet.DataMapper;
>
>
>
> namespace iBatis
>
> {
>
>       /// <summary>
>
>       /// Base class for Mapper objects (*Mapper).
>
>       /// Provides shared utility methods.
>
>       /// </summary>
>
>       public abstract class MapperBase
>
>       {
>
>             public SqlMapper Mapper()
>
>             {
>
>                   return IBatisNet.DataMapper.Mapper.Instance ();
>
>             }
>
>       }
>
> }
>
>
>
>  ________________________________
>
>
>
>
> This e-mail message and any files transmitted herewith, are intended solely
> for the use of the individual(s) addressed and may contain confidential,
> proprietary or privileged information.  If you are not the addressee
> indicated in this message (or responsible for delivery of this message to
> such person) you may not review, use, disclose or distribute this message or
> any files transmitted herewith.  If you receive this message in error,
> please contact the sender by reply e-mail and delete this message and all
> copies of it from your system.
>
>  ________________________________
>
>
>
>
>
>
>
>
>
>
>

RE: Newbie ibatis Tutorial Error

Posted by "Nguyen, Tom" <To...@rels.info>.
As the error said, you have two choices:

 

             public ISqlMapper Mapper()

            {

                  return IBatisNet.DataMapper.Mapper.Instance();

            }

 

Or:

             public SqlMapper Mapper()

            {

                  return (IBatisNet.DataMapper.Mapper.Instance() as
SqlMapper);

            }

 

 

Regards,


Tom Nguyen 
Sr. Developer
tom.nguyen@rels.info <ma...@rels.info> 



________________________________

From: Frank van Tour [mailto:fvantour@wanadoo.nl] 
Sent: Monday, October 22, 2007 2:46 PM
To: user-cs@ibatis.apache.org
Subject: Newbie ibatis Tutorial Error

 

Hi ,

 

Just started with ibatis tutorial 1.2.1. ( the .net 2.0 tutorial URL
failed to download ??).

In the singleton class ( as listed below ) I got the following error
(Using VS2005 and .Net 2.0)

 

 

Cannot implicitly convert type 'IBatisNet.DataMapper.ISqlMapper' to
'IBatisNet.DataMapper.SqlMapper'. 

An explicit conversion exists (are you missing a cast?)

 

Any clues what's going on here?

 

-Frank

 

using IBatisNet.DataMapper;

 

namespace iBatis

{

      /// <summary>

      /// Base class for Mapper objects (*Mapper). 

      /// Provides shared utility methods.

      /// </summary>

      public abstract class MapperBase

      {           

            public SqlMapper Mapper()

            {

                  return IBatisNet.DataMapper.Mapper.Instance ();

            }

      }

}

 


************************************************************************************
This e-mail message and any files transmitted herewith, are intended solely for the
use of the individual(s) addressed and may contain confidential, proprietary or 
privileged information.  If you are not the addressee indicated in this message 
(or responsible for delivery of this message to such person) you may not review, 
use, disclose or distribute this message or any files transmitted herewith.  If you 
receive this message in error, please contact the sender by reply e-mail and delete
this message and all copies of it from your system.
************************************************************************************