Re: Digest for mybatis-user@googlegroups.com - 3 updates in 2 topics

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Digest for mybatis-user@googlegroups.com - 3 updates in 2 topics

Vladimir Alarcon
Thank you Harawata for your solution. It was exactly what I needed. It
was so much simpler than I expected; I guess I was looking at the
wrong place. Also, I'll consider the performance implications.

Thank you again,
Vlad


On 5/28/19, [hidden email] <[hidden email]> wrote:

> =============================================================================
> Today's topic summary
> =============================================================================
>
> Group: [hidden email]
> Url:
>
> https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/mybatis-user/topics
>
>
>   - MyBatis+Spring - Retrieve VOs as "beans" [2 Updates]
>     http://groups.google.com/group/mybatis-user/t/4171bc64b18f868
>     http://groups.google.com/group/mybatis-user/t/a606b8b4ce775358
>
>
> =============================================================================
> Topic: MyBatis+Spring - Retrieve VOs as "beans"
> Url: http://groups.google.com/group/mybatis-user/t/4171bc64b18f868
> =============================================================================
>
> ---------- 1 of 2 ----------
> From: "Iwao AVE!" <[hidden email]>
> Date: May 28 10:51PM +0900
> Url: http://groups.google.com/group/mybatis-user/msg/1b298119d027b
>
> Hi Vlad,
>
> I would like them to be able to control Spring SQL transactions.
>
> I am not sure what that means, but it is possible to let MyBatis use Spring
> managed beans.
>
> You need to create a custom ObjectFactory
> <https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/reflection/factory/ObjectFactory.java>
> that looks up ApplicationContext.
> The create method would look as follows.
>
> public <T> T create(Class<T> type) {
>   try {
>     return applicationContext.getBean(type);
>   } catch (NoSuchBeanDefinitionException e) {
>     return delegate.create(type);
>   }
> }
>
> delegate is an instance of DefaultObjectFactory.
>
> Set this ObjectFactory to your SqlSessionFactoryBean.
>
> @Beanpublic SqlSessionFactoryBean sqlSessionFactory() {
>   SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
>   sessionFactory.setObjectFactory(new
> SpringBeanObjectFactory(applicationContext));
>   ...
>
> Here is an executable demo:
> https://github.com/harawata/mybatis-issues/tree/master/ml-20190524T021118
>
> Regards,
> Iwao
>
> On Fri, May 24, 2019 at 11:11 PM Vladimir Alarcon <[hidden email]>
> wrote:
>
>
>
> ---------- 2 of 2 ----------
> From: Kazuki Shimizu <[hidden email]>
> Date: May 28 10:37AM -0700
> Url: http://groups.google.com/group/mybatis-user/msg/5040d7ca9fc71
>
> Be careful a performance degradation when use the spring managed prototype
> bean.
>
> On Tuesday, May 28, 2019 at 10:52:10 PM UTC+9, Iwao AVE! wrote:
>
> --
> You received this digest because you're subscribed to updates for this
> group. You can change your settings on the group membership page:
>
> https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/mybatis-user/join
> .
> To unsubscribe from this group and stop receiving emails from it send an
> email to [hidden email].
>
>

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CAP3Y0VbPYe9cjx25RGrK9oWgzx7_taEpqOAWGVmasuDn%2BtAdGg%40mail.gmail.com.