ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick R <ric...@gmail.com>
Subject Re: Way to use sql in mapper interface, without having to create a corresponding xml mapping file?
Date Fri, 14 May 2010 01:21:26 GMT
Ok, cool maybe ill just change to this.

(By the way, I'm searching the archives for this, and it's sort of off-topic
but since you mentioned you create your datasource in XML - I'm curious how
do you declare the pool implementation that you want to use? I know ibatis
comes with a default one (not sure which one) but I was going to use the
latest commons-dbcp pool.)

On Thu, May 13, 2010 at 7:25 PM, Clinton Begin <clinton.begin@gmail.com>wrote:

> 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.
>>
>>
>>
>>
>>
>


-- 
Rick R

Mime
View raw message