ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: Select environment using XML
Date Wed, 28 Apr 2010 11:23:58 GMT
That's not runtime, either. :)

I think Alex's solution is adequate for the original question, but if
you really want to change it up on the fly, you should be able to
easily replace the SSF (assuming you have it as a singleton) the same
way - and if you add a function to your app that does it...bam, you're
done.

BTW (and only semi[ot]), I've been really pleased with how the
configuration API has changed in ibatis3. This kind of stuff is SO
much easier now. :-D

Larry


2010/4/28 Björn Raupach <raupach@e2n.de>:
> This is not run-time. You must redeploy the application. Why not select the environment
> based on a property file? This way you only need to restart the application.
>
> <environments default="${env}">
>
> Looks like a nice feature. Is there anything to be said against it?
>
>
>
> On Apr 28, 2010, at 3:02 AM, Alex Park wrote:
>
>> Hi,
>>
>> SqlSessionFactoryBuilder.build() method can select a specific environment in XML.
>>
>> For example,
>>
>> private Reader reader;
>> private SqlSessionFactory sqlSessionFactorys;
>> private SqlSession session;
>>
>> reader = Resources.getResourceAsReader("ibatis-config.xml");
>>
>> sqlSessionFactorys = new SqlSessionFactoryBuilder().build(reader, "test");
>> testSession = sqlSessionFactorys.openSession(); // test env
>>
>> sqlSessionFactorys = new SqlSessionFactoryBuilder().build(reader, "dev");
>> devSession = sqlSessionFactorys.openSession(); // dev env
>>
>>
>> Thanks,
>> Alex
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>

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


Mime
View raw message