You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by RichadB <ri...@aimhedge.com> on 2009/08/17 16:14:25 UTC

not known to the MapperRegistry with iBatis 3.0

Hello

 

I am new to iBatis and am trying to get started with the Beta version of
iBatis 3.0. 
I have set up a very simple test for myself this includes
An interface that defines the query
 

=========

package com.aimhedge.trading.database;

import java.util.List;

import org.apache.ibatis.annotations.Select;

public interface BackAdjFutureMapper {

       @Select("select * from back_adj_future " +

                    "where feed = #{feed} " +

                    "and instrument = #{instrument} " +

                    "and periodicity = 'DAILY' " +

                    "and field = #{field}")

                    List<BackAdjFuture> selectBackAdjFuture(BackAdjFuture
args);

=========


A class that maps getters and setters for all the columns in the table
back_adj_future and a top level class to test the simple select

=======

package com.aimhedge.trading.database;

import java.io.IOException;
import java.io.Reader;
import java.util.List;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;


public class MarketData {
       private SqlSessionFactory sqlSessionFactory;
       private SqlSession session;

       MarketData() throws IOException

       {

             String resource = "Configuration.xml";
             Reader reader = Resources.getResourceAsReader(resource);
             this.sqlSessionFactory = new
SqlSessionFactoryBuilder().build(reader);
             this.session = sqlSessionFactory.openSession();

             try 
             {
 	       BackAdjFuture args = new BackAdjFuture();
	       args.setFeed("CSI");
      	       args.setInstrument("BO");
	       args.setField("CLOSE");
	       BackAdjFutureMapper mapper =
this.session.getMapper(BackAdjFutureMapper.class);		      
List<BackAdjFuture> backAdjustedBoClose = mapper.selectBackAdjFuture(args);
             } 

             catch(Exception e)

             {
                    System.out.println(e.getMessage());
             }

             finally 

             {
                    session.close();
             }
       }

       

       public static void main(String args[]) throws IOException
       {
             MarketData runIt = new MarketData();
      }
}


=======

 

The code compiles fine but when I run it I get the message 
Type interface com.aimhedge.trading.database.BackAdjFutureMapper is not
known to the MapperRegistry.
It should be noted that in the Configuration.xml file that I pass in I
commented out the <mappers> section as I figured that I only had an
interface and no XML sqlMapper file. This is probably wrong but if it is I
don't know what to do.

Is anyone able to enlighten me as to what this means? 

 

Thanks

 

Richard

-- 
View this message in context: http://www.nabble.com/not-known-to-the-MapperRegistry-with-iBatis-3.0-tp25007484p25007484.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: not known to the MapperRegistry with iBatis 3.0

Posted by Clinton Begin <cl...@gmail.com>.
Actually, I think that would be very easy... I believe that's the way
it worked, before I added the explicit check for "knownMappers"...
have a look in the Configuration class.. there's a Map or Set called
knownMappers, and I think all it does is validate that it knows about
the mapper... :-)

That said, we do need to make sure a mapper is only added once.

Clinton

On Tue, Aug 18, 2009 at 9:33 AM, Nathan Maves<na...@gmail.com> wrote:
> Richard,
> I took a quick look at your example code.  I also took a look at the source
> and I think I see your issue.
> You are trying to use a java only Mapper class.  This works but right now
> the MapperRegistry getMapper method only looks though a collection of
> mappers.  So for now you will need to register it with the MapperRegistry.
>  Let me talk with the team about having the getMapper method also try to add
> it for you if it can't find it.  Sounds like a reasonable request.
> Nathan
>
> On Tue, Aug 18, 2009 at 1:21 AM, RichadB <ri...@aimhedge.com> wrote:
>>
>> Hi Clinton
>>
>> Given my inexperience I have zipped up my test eclipse project (don't
>> worry
>> it's pretty compact). and attached it. As far as I can tell it looks fine
>> (you should notice that commenting out the explicit loading of the mapper
>> causes the code to fail, uncommented things appear to work)
>>
>> Regards
>>
>> Richard
>>
>>
>> Clinton Begin wrote:
>> >
>> > If you could write a quick unit test to demonstrate the broken
>> > behavior, it might help.  Nathan just wrote a mapper and it was loaded
>> > automatically, so something must be different somewhere...
>> >
>> > Note:  The namespace must equal the fully qualified name of the CLASS,
>> > not the PACKAGE....
>> >
>> > Clinton
>> >
>> >  http://www.nabble.com/file/p25019720/MapperProblem.zip
>> > MapperProblem.zip
>> --
>> View this message in context:
>> http://www.nabble.com/not-known-to-the-MapperRegistry-with-iBatis-3.0-tp25007484p25019720.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: not known to the MapperRegistry with iBatis 3.0

Posted by Nathan Maves <na...@gmail.com>.
Richard,
I took a quick look at your example code.  I also took a look at the source
and I think I see your issue.

You are trying to use a java only Mapper class.  This works but right now
the MapperRegistry getMapper method only looks though a collection of
mappers.  So for now you will need to register it with the MapperRegistry.
 Let me talk with the team about having the getMapper method also try to add
it for you if it can't find it.  Sounds like a reasonable request.

Nathan

On Tue, Aug 18, 2009 at 1:21 AM, RichadB <ri...@aimhedge.com> wrote:

>
> Hi Clinton
>
> Given my inexperience I have zipped up my test eclipse project (don't worry
> it's pretty compact). and attached it. As far as I can tell it looks fine
> (you should notice that commenting out the explicit loading of the mapper
> causes the code to fail, uncommented things appear to work)
>
> Regards
>
> Richard
>
>
> Clinton Begin wrote:
> >
> > If you could write a quick unit test to demonstrate the broken
> > behavior, it might help.  Nathan just wrote a mapper and it was loaded
> > automatically, so something must be different somewhere...
> >
> > Note:  The namespace must equal the fully qualified name of the CLASS,
> > not the PACKAGE....
> >
> > Clinton
> >
> >  http://www.nabble.com/file/p25019720/MapperProblem.zipMapperProblem.zip
> --
> View this message in context:
> http://www.nabble.com/not-known-to-the-MapperRegistry-with-iBatis-3.0-tp25007484p25019720.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: not known to the MapperRegistry with iBatis 3.0

Posted by RichadB <ri...@aimhedge.com>.
Hi Clinton

Given my inexperience I have zipped up my test eclipse project (don't worry
it's pretty compact). and attached it. As far as I can tell it looks fine
(you should notice that commenting out the explicit loading of the mapper
causes the code to fail, uncommented things appear to work)

Regards

Richard


Clinton Begin wrote:
> 
> If you could write a quick unit test to demonstrate the broken
> behavior, it might help.  Nathan just wrote a mapper and it was loaded
> automatically, so something must be different somewhere...
> 
> Note:  The namespace must equal the fully qualified name of the CLASS,
> not the PACKAGE....
> 
> Clinton
> 
>  http://www.nabble.com/file/p25019720/MapperProblem.zip MapperProblem.zip 
-- 
View this message in context: http://www.nabble.com/not-known-to-the-MapperRegistry-with-iBatis-3.0-tp25007484p25019720.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: not known to the MapperRegistry with iBatis 3.0

Posted by Clinton Begin <cl...@gmail.com>.
If you could write a quick unit test to demonstrate the broken
behavior, it might help.  Nathan just wrote a mapper and it was loaded
automatically, so something must be different somewhere...

Note:  The namespace must equal the fully qualified name of the CLASS,
not the PACKAGE....

Clinton

On Mon, Aug 17, 2009 at 9:26 AM, RichadB<ri...@aimhedge.com> wrote:
>
> Adding the explicit mapping seems to work (or at least it gets me to another
> error of the sort I would expect to see). I don't think I'm doing anything
> strange, so I'm not sure why it doesn't automatically load
>
> Thanks Clinton
>
>
> Clinton Begin wrote:
>>
>> Strange, it should add it automatically if the namespace shares the
>> name of a class.  That said, you can add it manually...
>>
>> sqlSessionFactory.getConfiguration().addMapper(Your.class);
>>
>> I'll add this to the documentation.
>>
>> Clinton
>>
>>
> --
> View this message in context: http://www.nabble.com/not-known-to-the-MapperRegistry-with-iBatis-3.0-tp25007484p25008853.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: not known to the MapperRegistry with iBatis 3.0

Posted by RichadB <ri...@aimhedge.com>.
Adding the explicit mapping seems to work (or at least it gets me to another
error of the sort I would expect to see). I don't think I'm doing anything
strange, so I'm not sure why it doesn't automatically load

Thanks Clinton


Clinton Begin wrote:
> 
> Strange, it should add it automatically if the namespace shares the
> name of a class.  That said, you can add it manually...
> 
> sqlSessionFactory.getConfiguration().addMapper(Your.class);
> 
> I'll add this to the documentation.
> 
> Clinton
> 
> 
-- 
View this message in context: http://www.nabble.com/not-known-to-the-MapperRegistry-with-iBatis-3.0-tp25007484p25008853.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: not known to the MapperRegistry with iBatis 3.0

Posted by Clinton Begin <cl...@gmail.com>.
Strange, it should add it automatically if the namespace shares the
name of a class.  That said, you can add it manually...

sqlSessionFactory.getConfiguration().addMapper(Your.class);

I'll add this to the documentation.

Clinton

On Mon, Aug 17, 2009 at 8:14 AM, RichadB<ri...@aimhedge.com> wrote:
>
> Hello
>
>
>
> I am new to iBatis and am trying to get started with the Beta version of
> iBatis 3.0.
> I have set up a very simple test for myself this includes
> An interface that defines the query
>
>
> =========
>
> package com.aimhedge.trading.database;
>
> import java.util.List;
>
> import org.apache.ibatis.annotations.Select;
>
> public interface BackAdjFutureMapper {
>
>       @Select("select * from back_adj_future " +
>
>                    "where feed = #{feed} " +
>
>                    "and instrument = #{instrument} " +
>
>                    "and periodicity = 'DAILY' " +
>
>                    "and field = #{field}")
>
>                    List<BackAdjFuture> selectBackAdjFuture(BackAdjFuture
> args);
>
> =========
>
>
> A class that maps getters and setters for all the columns in the table
> back_adj_future and a top level class to test the simple select
>
> =======
>
> package com.aimhedge.trading.database;
>
> import java.io.IOException;
> import java.io.Reader;
> import java.util.List;
> import org.apache.ibatis.io.Resources;
> import org.apache.ibatis.session.SqlSession;
> import org.apache.ibatis.session.SqlSessionFactory;
> import org.apache.ibatis.session.SqlSessionFactoryBuilder;
>
>
> public class MarketData {
>       private SqlSessionFactory sqlSessionFactory;
>       private SqlSession session;
>
>       MarketData() throws IOException
>
>       {
>
>             String resource = "Configuration.xml";
>             Reader reader = Resources.getResourceAsReader(resource);
>             this.sqlSessionFactory = new
> SqlSessionFactoryBuilder().build(reader);
>             this.session = sqlSessionFactory.openSession();
>
>             try
>             {
>               BackAdjFuture args = new BackAdjFuture();
>               args.setFeed("CSI");
>               args.setInstrument("BO");
>               args.setField("CLOSE");
>               BackAdjFutureMapper mapper =
> this.session.getMapper(BackAdjFutureMapper.class);
> List<BackAdjFuture> backAdjustedBoClose = mapper.selectBackAdjFuture(args);
>             }
>
>             catch(Exception e)
>
>             {
>                    System.out.println(e.getMessage());
>             }
>
>             finally
>
>             {
>                    session.close();
>             }
>       }
>
>
>
>       public static void main(String args[]) throws IOException
>       {
>             MarketData runIt = new MarketData();
>      }
> }
>
>
> =======
>
>
>
> The code compiles fine but when I run it I get the message
> Type interface com.aimhedge.trading.database.BackAdjFutureMapper is not
> known to the MapperRegistry.
> It should be noted that in the Configuration.xml file that I pass in I
> commented out the <mappers> section as I figured that I only had an
> interface and no XML sqlMapper file. This is probably wrong but if it is I
> don't know what to do.
>
> Is anyone able to enlighten me as to what this means?
>
>
>
> Thanks
>
>
>
> Richard
>
> --
> View this message in context: http://www.nabble.com/not-known-to-the-MapperRegistry-with-iBatis-3.0-tp25007484p25007484.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org