You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Rick <ri...@gmail.com> on 2009/01/09 06:29:19 UTC

Using ibatis in a standalone jar with Spring, and also using spring in web tier

This is really more of a Spring question I guess, but I'll ask here first.

I want to have all my persistence classes (services and daos) that use
ibatis to be bundled in a standalone jar that my war (or possibly
multiple wars in an ear) can use. I'm using Spring for
mSqlMapClientDaoSupport and all my tests run fine. The architecture is
such that I have a service class that can call one or several daos in
each method. All of these beans are defined in my
application-context.xml.

In my webapp I'm also using Spring but I having difficulty
understanding how I set up things so that I can I have an isolated
application-context.xml file that loads for my persistence(ibatis) jar
and and another application-context.xml file for my webapp. Right now
I seem to have to delcare all the beans that my persistence jar is
using (services and daos) in my webapp application-xml. Isn't there a
way that I could get the beans defined in my persistence jar
initialized and then somehow used within my webapp classes? I'm
confused how to set this stuff up. Debating about just ditching using
Spring for my persistence jar.

-- 
Rick

Re: Using ibatis in a standalone jar with Spring, and also using spring in web tier

Posted by Rick <ri...@gmail.com>.
When you say you don't even use DAO anymore what do you mean. You mean
the ibatis or spring dao? you still have the concept of dao objects,
which then I'm assuming you just make calls directly on the
SqlMapClient in those dao methods?

I will have multiple databases unfortunately. I'll post in a bit what
I was planning on doing about it without using Spring and would like
some input if it's a decent approach.

On Fri, Jan 9, 2009 at 11:33 PM, Clinton Begin <cl...@gmail.com> wrote:
> For the record I don't even use DAO anymore.  It's an extra layer of
> abstraction that isn't needed unless you know out of the gate that you're
> going to have multiple persistence frameworks or databases.
>
> Cheers,
> Clinton
>
> On Fri, Jan 9, 2009 at 12:07 AM, Rick <ri...@gmail.com> wrote:
>>
>> I've looked at guice. I was liking using the SqlMapClientTemplate from
>> spring.
>>
>> I really don't even need Spring for the ibatis stuff, i was just using
>> it since I like how easy it was to load different slqMap configs into
>> different DAOs (since I'm going against different databases within the
>> app.) I'll look how The Pet Store does things and try that approach I
>> suppose. Is the Pet Store considered a good practice to follow?
>>
>>
>>
>> On Fri, Jan 9, 2009 at 12:56 AM, Nathan Maves <na...@gmail.com>
>> wrote:
>> > If all you need is DI check out guice.
>> >
>> > On Thu, Jan 8, 2009 at 10:49 PM, Rick <ri...@gmail.com> wrote:
>> >>
>> >> Sheesh look at this article...
>> >>
>> >> http://springtips.blogspot.com/2007/09/using-shared-context-from-ejbs.html
>> >>  it gives me a headache. How the heck can anyone justify using Spring
>> >> if you need to do the kind of stuff mentioned in that article. What a
>> >> royal pain.
>> >>
>> >> On Fri, Jan 9, 2009 at 12:31 AM, Rick <ri...@gmail.com> wrote:
>> >> > I meant spring-context not application-context, you know the spring
>> >> > config file:)
>> >> >
>> >> > On Fri, Jan 9, 2009 at 12:29 AM, Rick <ri...@gmail.com> wrote:
>> >> >> This is really more of a Spring question I guess, but I'll ask here
>> >> >> first.
>> >> >>
>> >> >> I want to have all my persistence classes (services and daos) that
>> >> >> use
>> >> >> ibatis to be bundled in a standalone jar that my war (or possibly
>> >> >> multiple wars in an ear) can use. I'm using Spring for
>> >> >> mSqlMapClientDaoSupport and all my tests run fine. The architecture
>> >> >> is
>> >> >> such that I have a service class that can call one or several daos
>> >> >> in
>> >> >> each method. All of these beans are defined in my
>> >> >> application-context.xml.
>> >> >>
>> >> >> In my webapp I'm also using Spring but I having difficulty
>> >> >> understanding how I set up things so that I can I have an isolated
>> >> >> application-context.xml file that loads for my persistence(ibatis)
>> >> >> jar
>> >> >> and and another application-context.xml file for my webapp. Right
>> >> >> now
>> >> >> I seem to have to delcare all the beans that my persistence jar is
>> >> >> using (services and daos) in my webapp application-xml. Isn't there
>> >> >> a
>> >> >> way that I could get the beans defined in my persistence jar
>> >> >> initialized and then somehow used within my webapp classes? I'm
>> >> >> confused how to set this stuff up. Debating about just ditching
>> >> >> using
>> >> >> Spring for my persistence jar.
>> >> >>
>> >> >> --
>> >> >> Rick
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Rick
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Rick
>> >
>> >
>>
>>
>>
>> --
>> Rick
>
>



-- 
Rick

Re: Using ibatis in a standalone jar with Spring, and also using spring in web tier

Posted by Clinton Begin <cl...@gmail.com>.
For the record I don't even use DAO anymore.  It's an extra layer of
abstraction that isn't needed unless you know out of the gate that you're
going to have multiple persistence frameworks or databases.

Cheers,
Clinton

On Fri, Jan 9, 2009 at 12:07 AM, Rick <ri...@gmail.com> wrote:

> I've looked at guice. I was liking using the SqlMapClientTemplate from
> spring.
>
> I really don't even need Spring for the ibatis stuff, i was just using
> it since I like how easy it was to load different slqMap configs into
> different DAOs (since I'm going against different databases within the
> app.) I'll look how The Pet Store does things and try that approach I
> suppose. Is the Pet Store considered a good practice to follow?
>
>
>
> On Fri, Jan 9, 2009 at 12:56 AM, Nathan Maves <na...@gmail.com>
> wrote:
> > If all you need is DI check out guice.
> >
> > On Thu, Jan 8, 2009 at 10:49 PM, Rick <ri...@gmail.com> wrote:
> >>
> >> Sheesh look at this article...
> >>
> http://springtips.blogspot.com/2007/09/using-shared-context-from-ejbs.html
> >>  it gives me a headache. How the heck can anyone justify using Spring
> >> if you need to do the kind of stuff mentioned in that article. What a
> >> royal pain.
> >>
> >> On Fri, Jan 9, 2009 at 12:31 AM, Rick <ri...@gmail.com> wrote:
> >> > I meant spring-context not application-context, you know the spring
> >> > config file:)
> >> >
> >> > On Fri, Jan 9, 2009 at 12:29 AM, Rick <ri...@gmail.com> wrote:
> >> >> This is really more of a Spring question I guess, but I'll ask here
> >> >> first.
> >> >>
> >> >> I want to have all my persistence classes (services and daos) that
> use
> >> >> ibatis to be bundled in a standalone jar that my war (or possibly
> >> >> multiple wars in an ear) can use. I'm using Spring for
> >> >> mSqlMapClientDaoSupport and all my tests run fine. The architecture
> is
> >> >> such that I have a service class that can call one or several daos in
> >> >> each method. All of these beans are defined in my
> >> >> application-context.xml.
> >> >>
> >> >> In my webapp I'm also using Spring but I having difficulty
> >> >> understanding how I set up things so that I can I have an isolated
> >> >> application-context.xml file that loads for my persistence(ibatis)
> jar
> >> >> and and another application-context.xml file for my webapp. Right now
> >> >> I seem to have to delcare all the beans that my persistence jar is
> >> >> using (services and daos) in my webapp application-xml. Isn't there a
> >> >> way that I could get the beans defined in my persistence jar
> >> >> initialized and then somehow used within my webapp classes? I'm
> >> >> confused how to set this stuff up. Debating about just ditching using
> >> >> Spring for my persistence jar.
> >> >>
> >> >> --
> >> >> Rick
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Rick
> >> >
> >>
> >>
> >>
> >> --
> >> Rick
> >
> >
>
>
>
> --
> Rick
>

Re: Using ibatis in a standalone jar with Spring, and also using spring in web tier

Posted by Rick <ri...@gmail.com>.
I've looked at guice. I was liking using the SqlMapClientTemplate from spring.

I really don't even need Spring for the ibatis stuff, i was just using
it since I like how easy it was to load different slqMap configs into
different DAOs (since I'm going against different databases within the
app.) I'll look how The Pet Store does things and try that approach I
suppose. Is the Pet Store considered a good practice to follow?



On Fri, Jan 9, 2009 at 12:56 AM, Nathan Maves <na...@gmail.com> wrote:
> If all you need is DI check out guice.
>
> On Thu, Jan 8, 2009 at 10:49 PM, Rick <ri...@gmail.com> wrote:
>>
>> Sheesh look at this article...
>> http://springtips.blogspot.com/2007/09/using-shared-context-from-ejbs.html
>>  it gives me a headache. How the heck can anyone justify using Spring
>> if you need to do the kind of stuff mentioned in that article. What a
>> royal pain.
>>
>> On Fri, Jan 9, 2009 at 12:31 AM, Rick <ri...@gmail.com> wrote:
>> > I meant spring-context not application-context, you know the spring
>> > config file:)
>> >
>> > On Fri, Jan 9, 2009 at 12:29 AM, Rick <ri...@gmail.com> wrote:
>> >> This is really more of a Spring question I guess, but I'll ask here
>> >> first.
>> >>
>> >> I want to have all my persistence classes (services and daos) that use
>> >> ibatis to be bundled in a standalone jar that my war (or possibly
>> >> multiple wars in an ear) can use. I'm using Spring for
>> >> mSqlMapClientDaoSupport and all my tests run fine. The architecture is
>> >> such that I have a service class that can call one or several daos in
>> >> each method. All of these beans are defined in my
>> >> application-context.xml.
>> >>
>> >> In my webapp I'm also using Spring but I having difficulty
>> >> understanding how I set up things so that I can I have an isolated
>> >> application-context.xml file that loads for my persistence(ibatis) jar
>> >> and and another application-context.xml file for my webapp. Right now
>> >> I seem to have to delcare all the beans that my persistence jar is
>> >> using (services and daos) in my webapp application-xml. Isn't there a
>> >> way that I could get the beans defined in my persistence jar
>> >> initialized and then somehow used within my webapp classes? I'm
>> >> confused how to set this stuff up. Debating about just ditching using
>> >> Spring for my persistence jar.
>> >>
>> >> --
>> >> Rick
>> >>
>> >
>> >
>> >
>> > --
>> > Rick
>> >
>>
>>
>>
>> --
>> Rick
>
>



-- 
Rick

Re: Using ibatis in a standalone jar with Spring, and also using spring in web tier

Posted by Nathan Maves <na...@gmail.com>.
If all you need is DI check out guice.

On Thu, Jan 8, 2009 at 10:49 PM, Rick <ri...@gmail.com> wrote:

> Sheesh look at this article...
> http://springtips.blogspot.com/2007/09/using-shared-context-from-ejbs.html
>  it gives me a headache. How the heck can anyone justify using Spring
> if you need to do the kind of stuff mentioned in that article. What a
> royal pain.
>
> On Fri, Jan 9, 2009 at 12:31 AM, Rick <ri...@gmail.com> wrote:
> > I meant spring-context not application-context, you know the spring
> > config file:)
> >
> > On Fri, Jan 9, 2009 at 12:29 AM, Rick <ri...@gmail.com> wrote:
> >> This is really more of a Spring question I guess, but I'll ask here
> first.
> >>
> >> I want to have all my persistence classes (services and daos) that use
> >> ibatis to be bundled in a standalone jar that my war (or possibly
> >> multiple wars in an ear) can use. I'm using Spring for
> >> mSqlMapClientDaoSupport and all my tests run fine. The architecture is
> >> such that I have a service class that can call one or several daos in
> >> each method. All of these beans are defined in my
> >> application-context.xml.
> >>
> >> In my webapp I'm also using Spring but I having difficulty
> >> understanding how I set up things so that I can I have an isolated
> >> application-context.xml file that loads for my persistence(ibatis) jar
> >> and and another application-context.xml file for my webapp. Right now
> >> I seem to have to delcare all the beans that my persistence jar is
> >> using (services and daos) in my webapp application-xml. Isn't there a
> >> way that I could get the beans defined in my persistence jar
> >> initialized and then somehow used within my webapp classes? I'm
> >> confused how to set this stuff up. Debating about just ditching using
> >> Spring for my persistence jar.
> >>
> >> --
> >> Rick
> >>
> >
> >
> >
> > --
> > Rick
> >
>
>
>
> --
> Rick
>

Re: Using ibatis in a standalone jar with Spring, and also using spring in web tier

Posted by Rick <ri...@gmail.com>.
Sheesh look at this article...
http://springtips.blogspot.com/2007/09/using-shared-context-from-ejbs.html
 it gives me a headache. How the heck can anyone justify using Spring
if you need to do the kind of stuff mentioned in that article. What a
royal pain.

On Fri, Jan 9, 2009 at 12:31 AM, Rick <ri...@gmail.com> wrote:
> I meant spring-context not application-context, you know the spring
> config file:)
>
> On Fri, Jan 9, 2009 at 12:29 AM, Rick <ri...@gmail.com> wrote:
>> This is really more of a Spring question I guess, but I'll ask here first.
>>
>> I want to have all my persistence classes (services and daos) that use
>> ibatis to be bundled in a standalone jar that my war (or possibly
>> multiple wars in an ear) can use. I'm using Spring for
>> mSqlMapClientDaoSupport and all my tests run fine. The architecture is
>> such that I have a service class that can call one or several daos in
>> each method. All of these beans are defined in my
>> application-context.xml.
>>
>> In my webapp I'm also using Spring but I having difficulty
>> understanding how I set up things so that I can I have an isolated
>> application-context.xml file that loads for my persistence(ibatis) jar
>> and and another application-context.xml file for my webapp. Right now
>> I seem to have to delcare all the beans that my persistence jar is
>> using (services and daos) in my webapp application-xml. Isn't there a
>> way that I could get the beans defined in my persistence jar
>> initialized and then somehow used within my webapp classes? I'm
>> confused how to set this stuff up. Debating about just ditching using
>> Spring for my persistence jar.
>>
>> --
>> Rick
>>
>
>
>
> --
> Rick
>



-- 
Rick

Re: Using ibatis in a standalone jar with Spring, and also using spring in web tier

Posted by Rick <ri...@gmail.com>.
I meant spring-context not application-context, you know the spring
config file:)

On Fri, Jan 9, 2009 at 12:29 AM, Rick <ri...@gmail.com> wrote:
> This is really more of a Spring question I guess, but I'll ask here first.
>
> I want to have all my persistence classes (services and daos) that use
> ibatis to be bundled in a standalone jar that my war (or possibly
> multiple wars in an ear) can use. I'm using Spring for
> mSqlMapClientDaoSupport and all my tests run fine. The architecture is
> such that I have a service class that can call one or several daos in
> each method. All of these beans are defined in my
> application-context.xml.
>
> In my webapp I'm also using Spring but I having difficulty
> understanding how I set up things so that I can I have an isolated
> application-context.xml file that loads for my persistence(ibatis) jar
> and and another application-context.xml file for my webapp. Right now
> I seem to have to delcare all the beans that my persistence jar is
> using (services and daos) in my webapp application-xml. Isn't there a
> way that I could get the beans defined in my persistence jar
> initialized and then somehow used within my webapp classes? I'm
> confused how to set this stuff up. Debating about just ditching using
> Spring for my persistence jar.
>
> --
> Rick
>



-- 
Rick