Re: Spring 3.X integration subproject started

classic Classic list List threaded Threaded
41 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Eduardo Macarron
Hi there Simo,

Sorry for my late reply.

In the last zip I posted at spring's jira you can find two tests that
I think are quite helpful.

The first one was one that Anger Clown wrote to test transactions.

The second one is more like an example. It just loads a memory
database, injects a mapper in a managed bean and makes a query. Its
purpose is to show how to make code that uses mybatis and spring
without importing any Class from spring or mybatis.

There are no tests yet for other usage scenarios like getting a mapper
or getting a SqlSession but they are quite trival.

Someone wrote a small manual based on my example at this spanish java
site:
http://www.javahispano.org/contenidos/es/mybatis_3__spring_3_1_para_los_que_les_gusta_el_sql_/

Unfortunately its in spanish but I think you will be able to read it
(the code is almost enough to see how it works altough some xml is not
well formatted).

I will download and test the code on svn as soon as I get back to home
on wednesday.


On 20 ago, 07:23, Simone Tripodi <[hidden email]> wrote:

> Hi Josh,
> honestly... not yet :P BTW I intend to add the Reference Guide in both
> PDF & Wiki, but since we're just at the beginning of the development
> I'd like to see some testcases before.
> Every kind of help will be much more than appreciated, patches are welcome!
> Have a nice day,
> Simo
>
> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
>
>
> On Fri, Aug 20, 2010 at 12:39 AM, josh <[hidden email]> wrote:
> > Hi Simon,
>
> > Will there be an initiative to provide any documentation for the new
> > subprojects (Spring 3 integration and Cache) on the MyBatis site or
> > the Wiki?
>
> > Thanks,
> > Josh
>
> > On Aug 19, 12:32 am, Simone Tripodi <[hidden email]> wrote:
> >> Hi Raj,
> >> I'm sure that most users here agree on using an embedded db like
> >> Apache Derby for testing since it doesn't require any preliminary
> >> action to test the package. Just checkout the code, run tests, that's
> >> all. That's the way how the MyBatis core has been tested for ages
> >> since the early days of iBATIS 1.X
> >> IMHO tests are not so portable at the level that just putting a
> >> different JDBC driver they can be run on a different platform, because
> >> of the sql dialect that requires a minimum effort.
> >> All the best,
> >> Simo
>
> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> >> On Thu, Aug 19, 2010 at 1:07 AM, Raj Nagappan <[hidden email]> wrote:
> >> > Hi Simo,
>
> >> > Nice to meet you too. Thanks for the testing ideas :-)
>
> >> > I'll be away for a week and a half but I plan on trying out most of
> >> > these tests during that time. It doesn't really look like many of them
> >> > can be checked in as repeatable unit tests though? I could check in
> >> > some mysql scripts to create the tables and run tests against them etc
> >> > (this is what we do for our own unit tests though portability/
> >> > replication of the database is not an issue for us).
>
> >> > I thought of maybe using an embedded derby DB instead for the tests,
> >> > but I prefer a full mysql instance for verifying the implementation.
> >> > This way if someone wanted to port the tests to postgress or some
> >> > other DB they could just change the drivers etc.
>
> >> > Raj.
>
> >> > On Aug 17, 3:54 pm, Simone Tripodi <[hidden email]> wrote:
> >> >> Hi Raj,
> >> >> very nice to meet you and to see more people involved!!! Honestly I
> >> >> still haven't had time to start implementing the tests since I'm not a
> >> >> Spring user at all - I should start studying Spring first - but
> >> >> Christian Poitras suggested me the following interesting points, you
> >> >> could start from there if you intend to submit patches:
>
> >> >> 1) MyBatis and Spring initialization succeeds when properly configured.
> >> >> 2) It is possible to inject a SqlSessionFactory instance in some DAO.
> >> >> 3) Changes are really done on the database.
> >> >> 4) It is possible to get an instance of some object in the database
> >> >> using MyBatis and Spring.
> >> >> 5) Transactions are supported.
>
> >> >> Please do an 'svn co' before working since sometimes I do minor-minor
> >> >> changes taking advance I've to study the codebase :P
> >> >> Thank you very much in advance for your contributions!
> >> >> Simo
>
> >> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> >> >> On Tue, Aug 17, 2010 at 1:14 AM, Raj Nagappan <[hidden email]> wrote:
> >> >> > Hi Simone,
>
> >> >> > Just quickly, I downloaded Spring 3, MyBatis 3 and Spring 3 - MyBatis
> >> >> > 3 integration, and made up a new project for it. I've only glanced at
> >> >> > it so far and it seems fine, but I've noticed that of the Javadoc is
> >> >> > busted and some @Overrides are missing and so on.
>
> >> >> > I'll see what I can do about figuring out some unit tests. Any
> >> >> > suggestions on how to test?
>
> >> >> > Raj.
>
> >> >> > On Aug 13, 3:39 pm, Simone Tripodi <[hidden email]> wrote:
> >> >> >> Hi Raj,
> >> >> >> your contribution will be more than welcome, that's what is really
> >> >> >> nice to hear! ;)
>
> >> >> >> The codebase was imported yesterday, please check it out from the
> >> >> >> mybatis subrojects[1], it would be nice if someone could attach
> >> >> >> patches to issues rather than paste code snippets on mail, it would
> >> >> >> simplify the development process.
>
> >> >> >> Thanks in advance to everybody, have a nice day!
> >> >> >> Simo
>
> >> >> >> [1]https://mybatis.googlecode.com/svn/sub-projects/mybatis-spring/trunk
>
> >> >> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> >> >> >> On Fri, Aug 13, 2010 at 1:38 AM, Raj Nagappan <[hidden email]> wrote:
> >> >> >> > Wow guys this is great to hear! It will be several weeks until I am in
> >> >> >> > a position to start working with this but I will definitely check it
> >> >> >> > out when I'm up to that.
>
> >> >> >> > Could I suggest that Andrius' config code above be stored in the
> >> >> >> > subproject somewhere? (if it's not already there). These config
> >> >> >> > snippets are really useful to get up and running with Spring
> >> >> >> > integration quickly.
>
> >> >> >> > Raj.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Simone Tripodi
Hola Eduardo,
thanks a lot for your hints. Today I had the chance to merge on trunk
the tests you pointed me in the zip files and they are currently
working.
Thanks for the documentation, I'm fluent in Spanish :) I'll start
translating it in the user manual ASAP so we should be ready to
publish an RC1 in a short while.
Hasta pronto!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sun, Aug 29, 2010 at 6:15 PM, Eduardo <[hidden email]> wrote:

> Hi there Simo,
>
> Sorry for my late reply.
>
> In the last zip I posted at spring's jira you can find two tests that
> I think are quite helpful.
>
> The first one was one that Anger Clown wrote to test transactions.
>
> The second one is more like an example. It just loads a memory
> database, injects a mapper in a managed bean and makes a query. Its
> purpose is to show how to make code that uses mybatis and spring
> without importing any Class from spring or mybatis.
>
> There are no tests yet for other usage scenarios like getting a mapper
> or getting a SqlSession but they are quite trival.
>
> Someone wrote a small manual based on my example at this spanish java
> site:
> http://www.javahispano.org/contenidos/es/mybatis_3__spring_3_1_para_los_que_les_gusta_el_sql_/
>
> Unfortunately its in spanish but I think you will be able to read it
> (the code is almost enough to see how it works altough some xml is not
> well formatted).
>
> I will download and test the code on svn as soon as I get back to home
> on wednesday.
>
>
> On 20 ago, 07:23, Simone Tripodi <[hidden email]> wrote:
>> Hi Josh,
>> honestly... not yet :P BTW I intend to add the Reference Guide in both
>> PDF & Wiki, but since we're just at the beginning of the development
>> I'd like to see some testcases before.
>> Every kind of help will be much more than appreciated, patches are welcome!
>> Have a nice day,
>> Simo
>>
>> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>>
>>
>>
>> On Fri, Aug 20, 2010 at 12:39 AM, josh <[hidden email]> wrote:
>> > Hi Simon,
>>
>> > Will there be an initiative to provide any documentation for the new
>> > subprojects (Spring 3 integration and Cache) on the MyBatis site or
>> > the Wiki?
>>
>> > Thanks,
>> > Josh
>>
>> > On Aug 19, 12:32 am, Simone Tripodi <[hidden email]> wrote:
>> >> Hi Raj,
>> >> I'm sure that most users here agree on using an embedded db like
>> >> Apache Derby for testing since it doesn't require any preliminary
>> >> action to test the package. Just checkout the code, run tests, that's
>> >> all. That's the way how the MyBatis core has been tested for ages
>> >> since the early days of iBATIS 1.X
>> >> IMHO tests are not so portable at the level that just putting a
>> >> different JDBC driver they can be run on a different platform, because
>> >> of the sql dialect that requires a minimum effort.
>> >> All the best,
>> >> Simo
>>
>> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>>
>> >> On Thu, Aug 19, 2010 at 1:07 AM, Raj Nagappan <[hidden email]> wrote:
>> >> > Hi Simo,
>>
>> >> > Nice to meet you too. Thanks for the testing ideas :-)
>>
>> >> > I'll be away for a week and a half but I plan on trying out most of
>> >> > these tests during that time. It doesn't really look like many of them
>> >> > can be checked in as repeatable unit tests though? I could check in
>> >> > some mysql scripts to create the tables and run tests against them etc
>> >> > (this is what we do for our own unit tests though portability/
>> >> > replication of the database is not an issue for us).
>>
>> >> > I thought of maybe using an embedded derby DB instead for the tests,
>> >> > but I prefer a full mysql instance for verifying the implementation.
>> >> > This way if someone wanted to port the tests to postgress or some
>> >> > other DB they could just change the drivers etc.
>>
>> >> > Raj.
>>
>> >> > On Aug 17, 3:54 pm, Simone Tripodi <[hidden email]> wrote:
>> >> >> Hi Raj,
>> >> >> very nice to meet you and to see more people involved!!! Honestly I
>> >> >> still haven't had time to start implementing the tests since I'm not a
>> >> >> Spring user at all - I should start studying Spring first - but
>> >> >> Christian Poitras suggested me the following interesting points, you
>> >> >> could start from there if you intend to submit patches:
>>
>> >> >> 1) MyBatis and Spring initialization succeeds when properly configured.
>> >> >> 2) It is possible to inject a SqlSessionFactory instance in some DAO.
>> >> >> 3) Changes are really done on the database.
>> >> >> 4) It is possible to get an instance of some object in the database
>> >> >> using MyBatis and Spring.
>> >> >> 5) Transactions are supported.
>>
>> >> >> Please do an 'svn co' before working since sometimes I do minor-minor
>> >> >> changes taking advance I've to study the codebase :P
>> >> >> Thank you very much in advance for your contributions!
>> >> >> Simo
>>
>> >> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>>
>> >> >> On Tue, Aug 17, 2010 at 1:14 AM, Raj Nagappan <[hidden email]> wrote:
>> >> >> > Hi Simone,
>>
>> >> >> > Just quickly, I downloaded Spring 3, MyBatis 3 and Spring 3 - MyBatis
>> >> >> > 3 integration, and made up a new project for it. I've only glanced at
>> >> >> > it so far and it seems fine, but I've noticed that of the Javadoc is
>> >> >> > busted and some @Overrides are missing and so on.
>>
>> >> >> > I'll see what I can do about figuring out some unit tests. Any
>> >> >> > suggestions on how to test?
>>
>> >> >> > Raj.
>>
>> >> >> > On Aug 13, 3:39 pm, Simone Tripodi <[hidden email]> wrote:
>> >> >> >> Hi Raj,
>> >> >> >> your contribution will be more than welcome, that's what is really
>> >> >> >> nice to hear! ;)
>>
>> >> >> >> The codebase was imported yesterday, please check it out from the
>> >> >> >> mybatis subrojects[1], it would be nice if someone could attach
>> >> >> >> patches to issues rather than paste code snippets on mail, it would
>> >> >> >> simplify the development process.
>>
>> >> >> >> Thanks in advance to everybody, have a nice day!
>> >> >> >> Simo
>>
>> >> >> >> [1]https://mybatis.googlecode.com/svn/sub-projects/mybatis-spring/trunk
>>
>> >> >> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>>
>> >> >> >> On Fri, Aug 13, 2010 at 1:38 AM, Raj Nagappan <[hidden email]> wrote:
>> >> >> >> > Wow guys this is great to hear! It will be several weeks until I am in
>> >> >> >> > a position to start working with this but I will definitely check it
>> >> >> >> > out when I'm up to that.
>>
>> >> >> >> > Could I suggest that Andrius' config code above be stored in the
>> >> >> >> > subproject somewhere? (if it's not already there). These config
>> >> >> >> > snippets are really useful to get up and running with Spring
>> >> >> >> > integration quickly.
>>
>> >> >> >> > Raj.- Ocultar texto de la cita -
>>
>> - Mostrar texto de la cita -
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Raj Nagappan
Hi Simo,

I managed to test the first four of the 5 tests you mentioned above
with no real problems. I forgot to do the transaction test as we have
no need for manually managed transactions here.

I can commit the test code if you set me up with an svn login. But I
also see that you've managed to copy across some other tests too. Mine
are just simple junit tests, but they use the Spring context to set up
and provide everything as beans.

There was one possible bug that I found to do with lazy loading but I
think it's a Mybatis core issue so I will raise a new thread on it.

Raj.
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Raj Nagappan
One more thing, I wrote the tests using MySql because (a) that was the
simplest thing for me to do at the time, and (b) we use MySql so I had
to test it anyway. I can port it to Derby DB in the next few days
hopefully.

On Aug 30, 10:12 am, Raj Nagappan <[hidden email]> wrote:

> Hi Simo,
>
> I managed to test the first four of the 5 tests you mentioned above
> with no real problems. I forgot to do the transaction test as we have
> no need for manually managed transactions here.
>
> I can commit the test code if you set me up with an svn login. But I
> also see that you've managed to copy across some other tests too. Mine
> are just simple junit tests, but they use the Spring context to set up
> and provide everything as beans.
>
> There was one possible bug that I found to do with lazy loading but I
> think it's a Mybatis core issue so I will raise a new thread on it.
>
> Raj.
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Simone Tripodi
Hi Raj,
thanks for your support, unfortunately I don't have the rights to add
you in the committer list. What I can suggest you, is providing
patches through the issue tracker and show an active participation on
the project, so I can propose you at the team.
The already existing tests are realized using HSQL, it would be nice
if you can use it too.
Have a nice day!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Mon, Aug 30, 2010 at 2:26 AM, Raj Nagappan <[hidden email]> wrote:

> One more thing, I wrote the tests using MySql because (a) that was the
> simplest thing for me to do at the time, and (b) we use MySql so I had
> to test it anyway. I can port it to Derby DB in the next few days
> hopefully.
>
> On Aug 30, 10:12 am, Raj Nagappan <[hidden email]> wrote:
>> Hi Simo,
>>
>> I managed to test the first four of the 5 tests you mentioned above
>> with no real problems. I forgot to do the transaction test as we have
>> no need for manually managed transactions here.
>>
>> I can commit the test code if you set me up with an svn login. But I
>> also see that you've managed to copy across some other tests too. Mine
>> are just simple junit tests, but they use the Spring context to set up
>> and provide everything as beans.
>>
>> There was one possible bug that I found to do with lazy loading but I
>> think it's a Mybatis core issue so I will raise a new thread on it.
>>
>> Raj.
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Raj Nagappan
Ok give me a couple of days to port it to HSQL and I'll submit a patch
for it.

On Aug 30, 3:53 pm, Simone Tripodi <[hidden email]> wrote:

> Hi Raj,
> thanks for your support, unfortunately I don't have the rights to add
> you in the committer list. What I can suggest you, is providing
> patches through the issue tracker and show an active participation on
> the project, so I can propose you at the team.
> The already existing tests are realized using HSQL, it would be nice
> if you can use it too.
> Have a nice day!
> Simo
>
> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> On Mon, Aug 30, 2010 at 2:26 AM, Raj Nagappan <[hidden email]> wrote:
> > One more thing, I wrote the tests using MySql because (a) that was the
> > simplest thing for me to do at the time, and (b) we use MySql so I had
> > to test it anyway. I can port it to Derby DB in the next few days
> > hopefully.
>
> > On Aug 30, 10:12 am, Raj Nagappan <[hidden email]> wrote:
> >> Hi Simo,
>
> >> I managed to test the first four of the 5 tests you mentioned above
> >> with no real problems. I forgot to do the transaction test as we have
> >> no need for manually managed transactions here.
>
> >> I can commit the test code if you set me up with an svn login. But I
> >> also see that you've managed to copy across some other tests too. Mine
> >> are just simple junit tests, but they use the Spring context to set up
> >> and provide everything as beans.
>
> >> There was one possible bug that I found to do with lazy loading but I
> >> think it's a Mybatis core issue so I will raise a new thread on it.
>
> >> Raj.
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Clinton Begin
Administrator
Show us what you can do with the patch and the issue tracker... and we'll make you a committer shortly after. :-)

BTW:  patch doesn't necessarily have to be an svn/diff patch.  You can just submit the modified files, and we can diff them too.. sometimes that's easier.  

Clinton

On Mon, Aug 30, 2010 at 5:13 PM, Raj Nagappan <[hidden email]> wrote:
Ok give me a couple of days to port it to HSQL and I'll submit a patch
for it.

On Aug 30, 3:53 pm, Simone Tripodi <[hidden email]> wrote:
> Hi Raj,
> thanks for your support, unfortunately I don't have the rights to add
> you in the committer list. What I can suggest you, is providing
> patches through the issue tracker and show an active participation on
> the project, so I can propose you at the team.
> The already existing tests are realized using HSQL, it would be nice
> if you can use it too.
> Have a nice day!
> Simo
>
> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> On Mon, Aug 30, 2010 at 2:26 AM, Raj Nagappan <[hidden email]> wrote:
> > One more thing, I wrote the tests using MySql because (a) that was the
> > simplest thing for me to do at the time, and (b) we use MySql so I had
> > to test it anyway. I can port it to Derby DB in the next few days
> > hopefully.
>
> > On Aug 30, 10:12 am, Raj Nagappan <[hidden email]> wrote:
> >> Hi Simo,
>
> >> I managed to test the first four of the 5 tests you mentioned above
> >> with no real problems. I forgot to do the transaction test as we have
> >> no need for manually managed transactions here.
>
> >> I can commit the test code if you set me up with an svn login. But I
> >> also see that you've managed to copy across some other tests too. Mine
> >> are just simple junit tests, but they use the Spring context to set up
> >> and provide everything as beans.
>
> >> There was one possible bug that I found to do with lazy loading but I
> >> think it's a Mybatis core issue so I will raise a new thread on it.
>
> >> Raj.

dpc
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

dpc
In reply to this post by Eduardo Macarron
Here's an XML I've used based on your example also.  I've been running
a beta program (about 40+ mappers with no issues so far) using the fix
posted in the JIRA issue.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

        <!-- JNDI Data Source -->
        <bean id="DataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
                <property name="jndiName" value="java:comp/env/jdbc/myDataSource" />
                <property name="lookupOnStartup" value="false" />
                <property name="cache" value="true" />
                <property name="proxyInterface" value="javax.sql.DataSource" />
        </bean>

        <!-- SQL Session Factory / Template based on Mybatis/Spring
Integration JIRA Fix -->
        <bean id="sqlSessionFactory"
class="org.springframework.orm.ibatis3.SqlSessionFactoryBean">
                <property name="dataSource" ref="DataSource" />
                <property name="configLocation" value="classpath:mybatis/
sqlMapConfig.xml" />
        </bean>

        <bean id="sqlSessionTemplate"
class="org.springframework.orm.ibatis3.SqlSessionTemplate">
                <property name="sqlSessionFactory" ref="sqlSessionFactory" />
        </bean>

        <!-- DAO / Mapper -->
        <bean id="customerMapperFactory"
class="org.springframework.orm.ibatis3.support.MapperFactoryBean" >
                <property name="sqlSessionTemplate" ref="sqlSessionTemplate" />
                <property name="mapperInterface" value="org.example.CustomerDAO" />
        </bean>

        <!-- Services -->
        <bean id="CustomerFinder"
class="org.example.services.impl.MybatisCustomerFinderImpl" >
                <constructor-arg><ref bean="customerMapperFactory"/></constructor-
arg>
        </bean>
</beans>


On Aug 29, 12:15 pm, Eduardo <[hidden email]> wrote:

> Hi there Simo,
>
> Sorry for my late reply.
>
> In the last zip I posted at spring's jira you can find two tests that
> I think are quite helpful.
>
> The first one was one that Anger Clown wrote to test transactions.
>
> The second one is more like an example. It just loads a memory
> database, injects a mapper in a managed bean and makes a query. Its
> purpose is to show how to make code that uses mybatis and spring
> without importing any Class from spring or mybatis.
>
> There are no tests yet for other usage scenarios like getting a mapper
> or getting a SqlSession but they are quite trival.
>
> Someone wrote a small manual based on my example at this spanish java
> site:http://www.javahispano.org/contenidos/es/mybatis_3__spring_3_1_para_l...
>
> Unfortunately its in spanish but I think you will be able to read it
> (the code is almost enough to see how it works altough some xml is not
> well formatted).
>
> I will download and test the code on svn as soon as I get back to home
> on wednesday.
>
> On 20 ago, 07:23, Simone Tripodi <[hidden email]> wrote:
>
> > Hi Josh,
> > honestly... not yet :P BTW I intend to add the Reference Guide in both
> > PDF & Wiki, but since we're just at the beginning of the development
> > I'd like to see some testcases before.
> > Every kind of help will be much more than appreciated, patches are welcome!
> > Have a nice day,
> > Simo
>
> >http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> > On Fri, Aug 20, 2010 at 12:39 AM, josh <[hidden email]> wrote:
> > > Hi Simon,
>
> > > Will there be an initiative to provide any documentation for the new
> > > subprojects (Spring 3 integration and Cache) on the MyBatis site or
> > > the Wiki?
>
> > > Thanks,
> > > Josh
>
> > > On Aug 19, 12:32 am, Simone Tripodi <[hidden email]> wrote:
> > >> Hi Raj,
> > >> I'm sure that most users here agree on using an embedded db like
> > >> Apache Derby for testing since it doesn't require any preliminary
> > >> action to test the package. Just checkout the code, run tests, that's
> > >> all. That's the way how the MyBatis core has been tested for ages
> > >> since the early days of iBATIS 1.X
> > >> IMHO tests are not so portable at the level that just putting a
> > >> different JDBC driver they can be run on a different platform, because
> > >> of the sql dialect that requires a minimum effort.
> > >> All the best,
> > >> Simo
>
> > >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> > >> On Thu, Aug 19, 2010 at 1:07 AM, Raj Nagappan <[hidden email]> wrote:
> > >> > Hi Simo,
>
> > >> > Nice to meet you too. Thanks for the testing ideas :-)
>
> > >> > I'll be away for a week and a half but I plan on trying out most of
> > >> > these tests during that time. It doesn't really look like many of them
> > >> > can be checked in as repeatable unit tests though? I could check in
> > >> > some mysql scripts to create the tables and run tests against them etc
> > >> > (this is what we do for our own unit tests though portability/
> > >> > replication of the database is not an issue for us).
>
> > >> > I thought of maybe using an embedded derby DB instead for the tests,
> > >> > but I prefer a full mysql instance for verifying the implementation.
> > >> > This way if someone wanted to port the tests to postgress or some
> > >> > other DB they could just change the drivers etc.
>
> > >> > Raj.
>
> > >> > On Aug 17, 3:54 pm, Simone Tripodi <[hidden email]> wrote:
> > >> >> Hi Raj,
> > >> >> very nice to meet you and to see more people involved!!! Honestly I
> > >> >> still haven't had time to start implementing the tests since I'm not a
> > >> >> Spring user at all - I should start studying Spring first - but
> > >> >> Christian Poitras suggested me the following interesting points, you
> > >> >> could start from there if you intend to submit patches:
>
> > >> >> 1) MyBatis and Spring initialization succeeds when properly configured.
> > >> >> 2) It is possible to inject a SqlSessionFactory instance in some DAO.
> > >> >> 3) Changes are really done on the database.
> > >> >> 4) It is possible to get an instance of some object in the database
> > >> >> using MyBatis and Spring.
> > >> >> 5) Transactions are supported.
>
> > >> >> Please do an 'svn co' before working since sometimes I do minor-minor
> > >> >> changes taking advance I've to study the codebase :P
> > >> >> Thank you very much in advance for your contributions!
> > >> >> Simo
>
> > >> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> > >> >> On Tue, Aug 17, 2010 at 1:14 AM, Raj Nagappan <[hidden email]> wrote:
> > >> >> > Hi Simone,
>
> > >> >> > Just quickly, I downloaded Spring 3, MyBatis 3 and Spring 3 - MyBatis
> > >> >> > 3 integration, and made up a new project for it. I've only glanced at
> > >> >> > it so far and it seems fine, but I've noticed that of the Javadoc is
> > >> >> > busted and some @Overrides are missing and so on.
>
> > >> >> > I'll see what I can do about figuring out some unit tests. Any
> > >> >> > suggestions on how to test?
>
> > >> >> > Raj.
>
> > >> >> > On Aug 13, 3:39 pm, Simone Tripodi <[hidden email]> wrote:
> > >> >> >> Hi Raj,
> > >> >> >> your contribution will be more than welcome, that's what is really
> > >> >> >> nice to hear! ;)
>
> > >> >> >> The codebase was imported yesterday, please check it out from the
> > >> >> >> mybatis subrojects[1], it would be nice if someone could attach
> > >> >> >> patches to issues rather than paste code snippets on mail, it would
> > >> >> >> simplify the development process.
>
> > >> >> >> Thanks in advance to everybody, have a nice day!
> > >> >> >> Simo
>
> > >> >> >> [1]https://mybatis.googlecode.com/svn/sub-projects/mybatis-spring/trunk
>
> > >> >> >>http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> > >> >> >> On Fri, Aug 13, 2010 at 1:38 AM, Raj Nagappan <[hidden email]> wrote:
> > >> >> >> > Wow guys this is great to hear! It will be several weeks until I am in
> > >> >> >> > a position to start working with this but I will definitely check it
> > >> >> >> > out when I'm up to that.
>
> > >> >> >> > Could I suggest that Andrius' config code above be stored in the
> > >> >> >> > subproject somewhere? (if it's not already there). These config
> > >> >> >> > snippets are really useful to get up and running with Spring
> > >> >> >> > integration quickly.
>
> > >> >> >> > Raj.- Ocultar texto de la cita -
>
> > - Mostrar texto de la cita -
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Eduardo Macarron
In reply to this post by Eduardo Macarron

Yep, tests run fine. So it seems that svn has de right code that
gathers all improvements and fixes (springs jira was a bit messed up).

For the guide. It should be similar to spring+ibatis2 guide
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/orm.html#orm-ibatis

The main difference is that there is an additional usage scenario: the
injected mappers.

There are three ways to use this code:
1.- Extending SqlSessionDaoSupport or using SqlSessionTemplate.
SqlSessionDaoSupport is a convenience class that provides a
SqlSessionTemplate. SqlSessionTemplate gives the application programer
the right SqlSession. Usage is similar to SqlMapClientDaoSupport (from
spring+ibatis2 paragraph 13.6.2). You just use the SqlSessionTemplate
to access mybatis API. You can also execute some custom code creating
a SqlSessionCallback. If you cannot or dont want to extend your DAOs
you get almost the same thing injecting a SqlSessionTemplate.

2.- Using SqlSession directly. Using this method you simply inject a
SqlSessionFactory on your bean and use it to create, use and close a
SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
aware that you cannot inject a SqlSession because this class is not
thread safe (the main difference from ibatis2)

3.- Using a MapperFactoryBean. You cannot do this with spring+ibatis2
so there is no info about it at springs site. It is explained in the
spanish page I posted + the small sample test. Using this method a
mapper is directly injected during initiation. Mybatis api is not used
on business code. IMO this is the easiest and simpler way (I should
have numbered it the first!! ) ;)

Scenarios 1 and 3 use the spring transaction manager to share
SqlSessions between different beans on the same thread.
Transactions are handled by spring. This scenarios also translate
mybatis exceptions into spring data access exceptions.

Scenario 2 has no spring transaction support and no exception
translation.

hope this helps.

regards!
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Simone Tripodi
Hola Edu,
thanks a lot, your suggestions help, of course. I'm going to prepare
the user docbook manual, I'd really appreciate if you - I mean all of
you - could periodically review and participate submitting patches.
Thanks again, have a nice day!!!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Tue, Aug 31, 2010 at 8:38 PM, Eduardo <[hidden email]> wrote:

>
> Yep, tests run fine. So it seems that svn has de right code that
> gathers all improvements and fixes (springs jira was a bit messed up).
>
> For the guide. It should be similar to spring+ibatis2 guide
> http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/orm.html#orm-ibatis
>
> The main difference is that there is an additional usage scenario: the
> injected mappers.
>
> There are three ways to use this code:
> 1.- Extending SqlSessionDaoSupport or using SqlSessionTemplate.
> SqlSessionDaoSupport is a convenience class that provides a
> SqlSessionTemplate. SqlSessionTemplate gives the application programer
> the right SqlSession. Usage is similar to SqlMapClientDaoSupport (from
> spring+ibatis2 paragraph 13.6.2). You just use the SqlSessionTemplate
> to access mybatis API. You can also execute some custom code creating
> a SqlSessionCallback. If you cannot or dont want to extend your DAOs
> you get almost the same thing injecting a SqlSessionTemplate.
>
> 2.- Using SqlSession directly. Using this method you simply inject a
> SqlSessionFactory on your bean and use it to create, use and close a
> SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
> aware that you cannot inject a SqlSession because this class is not
> thread safe (the main difference from ibatis2)
>
> 3.- Using a MapperFactoryBean. You cannot do this with spring+ibatis2
> so there is no info about it at springs site. It is explained in the
> spanish page I posted + the small sample test. Using this method a
> mapper is directly injected during initiation. Mybatis api is not used
> on business code. IMO this is the easiest and simpler way (I should
> have numbered it the first!! ) ;)
>
> Scenarios 1 and 3 use the spring transaction manager to share
> SqlSessions between different beans on the same thread.
> Transactions are handled by spring. This scenarios also translate
> mybatis exceptions into spring data access exceptions.
>
> Scenario 2 has no spring transaction support and no exception
> translation.
>
> hope this helps.
>
> regards!
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Eduardo Macarron
Take it for granted Simo.

On 31 ago, 21:18, Simone Tripodi <[hidden email]> wrote:

> Hola Edu,
> thanks a lot, your suggestions help, of course. I'm going to prepare
> the user docbook manual, I'd really appreciate if you - I mean all of
> you - could periodically review and participate submitting patches.
> Thanks again, have a nice day!!!
> Simo
>
> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
>
>
> On Tue, Aug 31, 2010 at 8:38 PM, Eduardo <[hidden email]> wrote:
>
> > Yep, tests run fine. So it seems that svn has de right code that
> > gathers all improvements and fixes (springs jira was a bit messed up).
>
> > For the guide. It should be similar to spring+ibatis2 guide
> >http://static.springsource.org/spring/docs/3.0.x/spring-framework-ref...
>
> > The main difference is that there is an additional usage scenario: the
> > injected mappers.
>
> > There are three ways to use this code:
> > 1.- Extending SqlSessionDaoSupport or using SqlSessionTemplate.
> > SqlSessionDaoSupport is a convenience class that provides a
> > SqlSessionTemplate. SqlSessionTemplate gives the application programer
> > the right SqlSession. Usage is similar to SqlMapClientDaoSupport (from
> > spring+ibatis2 paragraph 13.6.2). You just use the SqlSessionTemplate
> > to access mybatis API. You can also execute some custom code creating
> > a SqlSessionCallback. If you cannot or dont want to extend your DAOs
> > you get almost the same thing injecting a SqlSessionTemplate.
>
> > 2.- Using SqlSession directly. Using this method you simply inject a
> > SqlSessionFactory on your bean and use it to create, use and close a
> > SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
> > aware that you cannot inject a SqlSession because this class is not
> > thread safe (the main difference from ibatis2)
>
> > 3.- Using a MapperFactoryBean. You cannot do this with spring+ibatis2
> > so there is no info about it at springs site. It is explained in the
> > spanish page I posted + the small sample test. Using this method a
> > mapper is directly injected during initiation. Mybatis api is not used
> > on business code. IMO this is the easiest and simpler way (I should
> > have numbered it the first!! ) ;)
>
> > Scenarios 1 and 3 use the spring transaction manager to share
> > SqlSessions between different beans on the same thread.
> > Transactions are handled by spring. This scenarios also translate
> > mybatis exceptions into spring data access exceptions.
>
> > Scenario 2 has no spring transaction support and no exception
> > translation.
>
> > hope this helps.
>
> > regards!
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Raj Nagappan
In reply to this post by Simone Tripodi
Hi Simo,

I'm having a little trouble with the hsqldb port. I can't get Mybatis
to pick up the id number. This is what I have for the MySql version:

    <insert id="create" parameterType="Flavour">
        <selectKey keyProperty="id" resultType="int" order="AFTER"
statementType="PREPARED">
            select LAST_INSERT_ID() AS id
        </selectKey>
        insert into Flavour
            (id,
            name)
        values
            (#{id},
            #{name})
    </insert>

and I need the equivalent of the selectKey clause for hsqldb. The
hsqldb schema is pretty is simple:

CREATE TABLE  flavour (
  id int NOT NULL IDENTITY,
  name varchar(45) DEFAULT NULL
);

Any help would be appreciated.
Raj.

On Sep 1, 5:18 am, Simone Tripodi <[hidden email]> wrote:

> Hola Edu,
> thanks a lot, your suggestions help, of course. I'm going to prepare
> the user docbook manual, I'd really appreciate if you - I mean all of
> you - could periodically review and participate submitting patches.
> Thanks again, have a nice day!!!
> Simo
>
> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> On Tue, Aug 31, 2010 at 8:38 PM, Eduardo <[hidden email]> wrote:
>
> > Yep, tests run fine. So it seems that svn has de right code that
> > gathers all improvements and fixes (springs jira was a bit messed up).
>
> > For the guide. It should be similar to spring+ibatis2 guide
> >http://static.springsource.org/spring/docs/3.0.x/spring-framework-ref...
>
> > The main difference is that there is an additional usage scenario: the
> > injected mappers.
>
> > There are three ways to use this code:
> > 1.- Extending SqlSessionDaoSupport or using SqlSessionTemplate.
> > SqlSessionDaoSupport is a convenience class that provides a
> > SqlSessionTemplate. SqlSessionTemplate gives the application programer
> > the right SqlSession. Usage is similar to SqlMapClientDaoSupport (from
> > spring+ibatis2 paragraph 13.6.2). You just use the SqlSessionTemplate
> > to access mybatis API. You can also execute some custom code creating
> > a SqlSessionCallback. If you cannot or dont want to extend your DAOs
> > you get almost the same thing injecting a SqlSessionTemplate.
>
> > 2.- Using SqlSession directly. Using this method you simply inject a
> > SqlSessionFactory on your bean and use it to create, use and close a
> > SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
> > aware that you cannot inject a SqlSession because this class is not
> > thread safe (the main difference from ibatis2)
>
> > 3.- Using a MapperFactoryBean. You cannot do this with spring+ibatis2
> > so there is no info about it at springs site. It is explained in the
> > spanish page I posted + the small sample test. Using this method a
> > mapper is directly injected during initiation. Mybatis api is not used
> > on business code. IMO this is the easiest and simpler way (I should
> > have numbered it the first!! ) ;)
>
> > Scenarios 1 and 3 use the spring transaction manager to share
> > SqlSessions between different beans on the same thread.
> > Transactions are handled by spring. This scenarios also translate
> > mybatis exceptions into spring data access exceptions.
>
> > Scenario 2 has no spring transaction support and no exception
> > translation.
>
> > hope this helps.
>
> > regards!
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Eduardo Macarron
Hi Raj

If you are using identities I suppose you should enable
useGeneratedKeys=true and include the keyProperty attribute on your
insert statement.

If you want to use a selectkey substatement I suppose you should use
sequences instead of identities.

cheers!

On 4 sep, 09:38, Raj Nagappan <[hidden email]> wrote:

> Hi Simo,
>
> I'm having a little trouble with the hsqldb port. I can't get Mybatis
> to pick up the id number. This is what I have for the MySql version:
>
>     <insert id="create" parameterType="Flavour">
>         <selectKey keyProperty="id" resultType="int" order="AFTER"
> statementType="PREPARED">
>             select LAST_INSERT_ID() AS id
>         </selectKey>
>         insert into Flavour
>             (id,
>             name)
>         values
>             (#{id},
>             #{name})
>     </insert>
>
> and I need the equivalent of the selectKey clause for hsqldb. The
> hsqldb schema is pretty is simple:
>
> CREATE TABLE  flavour (
>   id int NOT NULL IDENTITY,
>   name varchar(45) DEFAULT NULL
> );
>
> Any help would be appreciated.
> Raj.
>
> On Sep 1, 5:18 am, Simone Tripodi <[hidden email]> wrote:
>
>
>
> > Hola Edu,
> > thanks a lot, your suggestions help, of course. I'm going to prepare
> > the user docbook manual, I'd really appreciate if you - I mean all of
> > you - could periodically review and participate submitting patches.
> > Thanks again, have a nice day!!!
> > Simo
>
> >http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> > On Tue, Aug 31, 2010 at 8:38 PM, Eduardo <[hidden email]> wrote:
>
> > > Yep, tests run fine. So it seems that svn has de right code that
> > > gathers all improvements and fixes (springs jira was a bit messed up).
>
> > > For the guide. It should be similar to spring+ibatis2 guide
> > >http://static.springsource.org/spring/docs/3.0.x/spring-framework-ref...
>
> > > The main difference is that there is an additional usage scenario: the
> > > injected mappers.
>
> > > There are three ways to use this code:
> > > 1.- Extending SqlSessionDaoSupport or using SqlSessionTemplate.
> > > SqlSessionDaoSupport is a convenience class that provides a
> > > SqlSessionTemplate. SqlSessionTemplate gives the application programer
> > > the right SqlSession. Usage is similar to SqlMapClientDaoSupport (from
> > > spring+ibatis2 paragraph 13.6.2). You just use the SqlSessionTemplate
> > > to access mybatis API. You can also execute some custom code creating
> > > a SqlSessionCallback. If you cannot or dont want to extend your DAOs
> > > you get almost the same thing injecting a SqlSessionTemplate.
>
> > > 2.- Using SqlSession directly. Using this method you simply inject a
> > > SqlSessionFactory on your bean and use it to create, use and close a
> > > SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
> > > aware that you cannot inject a SqlSession because this class is not
> > > thread safe (the main difference from ibatis2)
>
> > > 3.- Using a MapperFactoryBean. You cannot do this with spring+ibatis2
> > > so there is no info about it at springs site. It is explained in the
> > > spanish page I posted + the small sample test. Using this method a
> > > mapper is directly injected during initiation. Mybatis api is not used
> > > on business code. IMO this is the easiest and simpler way (I should
> > > have numbered it the first!! ) ;)
>
> > > Scenarios 1 and 3 use the spring transaction manager to share
> > > SqlSessions between different beans on the same thread.
> > > Transactions are handled by spring. This scenarios also translate
> > > mybatis exceptions into spring data access exceptions.
>
> > > Scenario 2 has no spring transaction support and no exception
> > > translation.
>
> > > hope this helps.
>
> > > regards!
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Raj Nagappan
In reply to this post by Simone Tripodi
Hi guys,

Sorry it took me so long but I ported the unit tests to HSQL and
submitted a zip file with the patch (and the unaltered source) to
http://code.google.com/p/mybatis/issues/detail?id=99

It's got everything in it (though I have not tested the maven pom). I
would have preferred to just create a patch but since I checked it out
anonymously I don't get svn changes marked in the source. No idea why
this is but I'm no svn expert. And I figure it's only temporary until
I can do a proper checkout.

Raj.

On Sep 1, 5:18 am, Simone Tripodi <[hidden email]> wrote:

> Hola Edu,
> thanks a lot, your suggestions help, of course. I'm going to prepare
> the user docbook manual, I'd really appreciate if you - I mean all of
> you - could periodically review and participate submitting patches.
> Thanks again, have a nice day!!!
> Simo
>
> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>
> On Tue, Aug 31, 2010 at 8:38 PM, Eduardo <[hidden email]> wrote:
>
> > Yep, tests run fine. So it seems that svn has de right code that
> > gathers all improvements and fixes (springs jira was a bit messed up).
>
> > For the guide. It should be similar tospring+ibatis2 guide
> >http://static.springsource.org/spring/docs/3.0.x/spring-framework-ref...
>
> > The main difference is that there is an additional usage scenario: the
> > injected mappers.
>
> > There are three ways to use this code:
> > 1.- Extending SqlSessionDaoSupport or using SqlSessionTemplate.
> > SqlSessionDaoSupport is a convenience class that provides a
> > SqlSessionTemplate. SqlSessionTemplate gives the application programer
> > the right SqlSession. Usage is similar to SqlMapClientDaoSupport (from
> >spring+ibatis2 paragraph 13.6.2). You just use the SqlSessionTemplate
> > to access mybatis API. You can also execute some custom code creating
> > a SqlSessionCallback. If you cannot or dont want to extend your DAOs
> > you get almost the same thing injecting a SqlSessionTemplate.
>
> > 2.- Using SqlSession directly. Using this method you simply inject a
> > SqlSessionFactory on your bean and use it to create, use and close a
> > SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
> > aware that you cannot inject a SqlSession because this class is not
> > thread safe (the main difference from ibatis2)
>
> > 3.- Using a MapperFactoryBean. You cannot do this withspring+ibatis2
> > so there is no info about it at springs site. It is explained in the
> > spanish page I posted + the small sample test. Using this method a
> > mapper is directly injected during initiation. Mybatis api is not used
> > on business code. IMO this is the easiest and simpler way (I should
> > have numbered it the first!! ) ;)
>
> > Scenarios 1 and 3 use thespringtransaction manager to share
> > SqlSessions between different beans on the same thread.
> > Transactions are handled byspring. This scenarios also translate
> > mybatis exceptions intospringdata access exceptions.
>
> > Scenario 2 has nospringtransaction support and no exception
> > translation.
>
> > hope this helps.
>
> > regards!
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Simone Tripodi
Hi Raj,
thanks for your help. Yesterday I applied a patch provided by Hunter,
I'd really appreciate if you could run your tests after an svn up.
About submitting patches: of course it would help a lot if you can
submit a *.patch file so it would be much more easier for me merging
the changes; after the checks, please try to run on shell:

svn diff

if it produces some output, then run

svn diff > mybatis-spring-junit-tests.patch

then open the output file to see the content. That will be the file
useful to be submitted through the Issue tracker.
Many thanks in advance, have a nice Sunday!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Sun, Sep 12, 2010 at 12:23 PM, Raj Nagappan <[hidden email]> wrote:

> Hi guys,
>
> Sorry it took me so long but I ported the unit tests to HSQL and
> submitted a zip file with the patch (and the unaltered source) to
> http://code.google.com/p/mybatis/issues/detail?id=99
>
> It's got everything in it (though I have not tested the maven pom). I
> would have preferred to just create a patch but since I checked it out
> anonymously I don't get svn changes marked in the source. No idea why
> this is but I'm no svn expert. And I figure it's only temporary until
> I can do a proper checkout.
>
> Raj.
>
> On Sep 1, 5:18 am, Simone Tripodi <[hidden email]> wrote:
>> Hola Edu,
>> thanks a lot, your suggestions help, of course. I'm going to prepare
>> the user docbook manual, I'd really appreciate if you - I mean all of
>> you - could periodically review and participate submitting patches.
>> Thanks again, have a nice day!!!
>> Simo
>>
>> http://people.apache.org/~simonetripodi/http://www.99soft.org/
>>
>> On Tue, Aug 31, 2010 at 8:38 PM, Eduardo <[hidden email]> wrote:
>>
>> > Yep, tests run fine. So it seems that svn has de right code that
>> > gathers all improvements and fixes (springs jira was a bit messed up).
>>
>> > For the guide. It should be similar tospring+ibatis2 guide
>> >http://static.springsource.org/spring/docs/3.0.x/spring-framework-ref...
>>
>> > The main difference is that there is an additional usage scenario: the
>> > injected mappers.
>>
>> > There are three ways to use this code:
>> > 1.- Extending SqlSessionDaoSupport or using SqlSessionTemplate.
>> > SqlSessionDaoSupport is a convenience class that provides a
>> > SqlSessionTemplate. SqlSessionTemplate gives the application programer
>> > the right SqlSession. Usage is similar to SqlMapClientDaoSupport (from
>> >spring+ibatis2 paragraph 13.6.2). You just use the SqlSessionTemplate
>> > to access mybatis API. You can also execute some custom code creating
>> > a SqlSessionCallback. If you cannot or dont want to extend your DAOs
>> > you get almost the same thing injecting a SqlSessionTemplate.
>>
>> > 2.- Using SqlSession directly. Using this method you simply inject a
>> > SqlSessionFactory on your bean and use it to create, use and close a
>> > SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
>> > aware that you cannot inject a SqlSession because this class is not
>> > thread safe (the main difference from ibatis2)
>>
>> > 3.- Using a MapperFactoryBean. You cannot do this withspring+ibatis2
>> > so there is no info about it at springs site. It is explained in the
>> > spanish page I posted + the small sample test. Using this method a
>> > mapper is directly injected during initiation. Mybatis api is not used
>> > on business code. IMO this is the easiest and simpler way (I should
>> > have numbered it the first!! ) ;)
>>
>> > Scenarios 1 and 3 use thespringtransaction manager to share
>> > SqlSessions between different beans on the same thread.
>> > Transactions are handled byspring. This scenarios also translate
>> > mybatis exceptions intospringdata access exceptions.
>>
>> > Scenario 2 has nospringtransaction support and no exception
>> > translation.
>>
>> > hope this helps.
>>
>> > regards!
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Arkadi Shishlov
In reply to this post by Eduardo Macarron
On Aug 31, 9:38 pm, Eduardo <[hidden email]> wrote:
> 2.- Using SqlSession directly. Using this method you simply inject a
> SqlSessionFactory on your bean and use it to create, use and close a
> SqlSession. This is similar to paragraph 13.6.3 on springs doc. Be
> aware that you cannot inject a SqlSession because this class is not
> thread safe (the main difference from ibatis2)
[snip]
> Scenario 2 has no spring transaction support and no exception
> translation.

Could you please elaborate why this scenario won't get @Transactional
support?
Lets not start the debate on DAO/SqlMapTemplate/whatever pattern, but
I find them too verbose and prefer to use SqlSession directly.
I understand, that there is now a problem to close SqlSession
(compared to iBatis 2.x), but after injecting SqlSessionFactory I'll
get same SqlSession as other parts of the code and it will be
protected by Spring transactional mechanism due to use of DataSource
supported by DataSourceTransactionManager.

The Spring transactions works with plain iBatis 2.x SqlMapClient,
right?
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Arkadi Shishlov
On Sep 13, 12:08 am, Arkadi <[hidden email]> wrote:
> Could you please elaborate why this scenario won't get @Transactional
> support?

I see there is SqlSessionUtils involved...
Do you have an idea how to use MyBatis with Spring 3.x in a plain CDI
way?
Without DAO, without SqlSessionTemplate, and without bothering to open
and close the SqlSession manually.
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Hunter
I guess Eduardo wasn't 100% correct in saying that using an SqlSession
directly couldn't be transactional. But, to make base SqlSessions work
with Spring transactions takes a large amount of work. In fact, this
is the work has already been done by the MyBatis-Spring code. So
anyone attempting this would end up re-implementing the same thing.

To make an SqlSession Spring transactional you have make sure to
always open the SqlSession with a Connection from an existing Spring
transaction. This is what the methods in SqlSessionUtils do. Note this
also assumes your SqlSessions are using the
SpringManagedTransactionFactory (the default if you are using
SqlSessionFactoryBean) and not the base MyBatis JDBC or
ManagedTransaction factory classes. Using either of the base MyBatis
transactions will cause problems.

If you don't want to manually close the SqlSession, you would have to
hook into the existing tx and have tx syncronization close the
SqlSession for you. SqlSessionUtils handles this too.
SqlSessionTemplate then handles calling SqlSessionUtils in a try,
catch, finally block.

So, the bottom line is that you probably better off to use
SqlSessionTemplate if you don't want to use any DAOs (or mapper
beans). SqlSessionTemplate's methods mimic SqlSession. You _can_
inject an SqlSessionTemplate into your beans since it is thread safe.
Finally, SqlSessionTemplate takes care of opening and closing the
SqlSession (and commiting / rolling back if a Spring tx is active).

Something like this should work just fine:
@Transactional
public Foo getFoo(int id) {
  return sqlSessionTemplate.selectOne("foo.findFoo", id);
}

On Sep 12, 5:27 pm, Arkadi <[hidden email]> wrote:

> On Sep 13, 12:08 am, Arkadi <[hidden email]> wrote:
>
> > Could you please elaborate why this scenario won't get @Transactional
> > support?
>
> I see there is SqlSessionUtils involved...
> Do you have an idea how to use MyBatis with Spring 3.x in a plain CDI
> way?
> Without DAO, without SqlSessionTemplate, and without bothering to open
> and close the SqlSession manually.
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Arkadi Shishlov
Thank you for the prompt answer.
I'll try SqlSessionTemplate.

Is it decided from which package the integration will be avaliable -
MyBatis or Spring Data?
ETA?
Reply | Threaded
Open this post in threaded view
|

Re: Spring 3.X integration subproject started

Simone Tripodi
Hi Arkadi,
thanks a lot for your interest on the mybatis-spring package!!!
At that stage this integration package will be released as MyBatis
subproject, if SpringSource would be interested on supporting MyBatis
we'll be more than glad to contribute at their integration. I want to
pose an emphasis that differently to other projects, mybatis-spring is
100% community-driven, I'm just putting a glue to all these smart
guys' stuff. If you want to contribute, feel free to open issues and
submit patches, they are more than welcome.
For what I can see we're ready to release an RC1 but the lack of
documentation is preventing me to do it, so until we won't terminate
at least a "5 minutes cookbook" I'd avoid to publish undocumented
stuff.
Involved people is working on that and let's hope we'll have the RC1 ASAP.
Have a nice day,
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Mon, Sep 13, 2010 at 2:02 AM, Arkadi <[hidden email]> wrote:
> Thank you for the prompt answer.
> I'll try SqlSessionTemplate.
>
> Is it decided from which package the integration will be avaliable -
> MyBatis or Spring Data?
> ETA?
123