ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
Date Thu, 13 May 2010 23:25:23 GMT
That would be a really simple change.

What I've been really getting used to though is configuring the datasource
in XML, and then using Java for most everything else.

For example, I have this in a class called IbatisConfig:

      final String resource = "com/myapp/data/IbatisConfig.xml";
      final Reader reader = Resources.getResourceAsReader(resource);
      final SqlSessionFactory sessionFactory = new
SqlSessionFactoryBuilder().build(reader);
      final Configuration configuration = sessionFactory.getConfiguration();
      TypeAliasRegistry typeAliasRegistry =
configuration.getTypeAliasRegistry();
      typeAliasRegistry.registerAlias(User.class);
      typeAliasRegistry.registerAlias(Project.class);
      typeAliasRegistry.registerAlias(Category.class);
      typeAliasRegistry.registerAlias(Type.class);
      configuration.addMapper(UserMapper.class);
      configuration.addMapper(ProjectMapper.class);
      configuration.addMapper(SessionMapper.class);
      return sessionFactory;

Clinton

On Thu, May 13, 2010 at 5:10 PM, Rick R <rickcr@gmail.com> wrote:

>
>
> On Thu, May 13, 2010 at 4:50 PM, Larry Meadors <larry.meadors@gmail.com>wrote:
>
>> He wants to represent that in the xml config.
>>
>
>
> Right. It seems odd that you can manually add the Mapper through Java (as
> Jeff has shown), but not through the xml config.
>
>
>
>
>

Mime
View raw message