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 "Albert L. Sapp" <as...@uiuc.edu> on 2004/12/29 23:38:26 UTC

SQL Maps and/or DAO

1.  Can someone explain to me how the DAO framework enhances the use of SQL 
Maps framework or is the DAO framework a replacement for SQL Maps 
framework?  Both of them seem to be used as transaction managers.  All I am 
wanting to do is some transaction processing against a Oracle database 
using a JDBC connection and SQL statements.

2.  When I look at the source code files for JPetStore, I can seem to 
follow what is happening.  It seems to only use SQL Maps.  Am I correct?

Once I know what the relationship between the two is, I may be able to 
figure out how to complete the project I am working on.  Right now, none of 
our dao.xml or sql-maps.xml files look very close to the pet store samples.

Thanks,

Al


Re: SQL Maps and/or DAO

Posted by Brandon Goodin <br...@gmail.com>.
SQLMaps can be used to access the database from within a DAO class.
The DAO Framework manages your DAO classes regardless of the mechanism
used to access the database.

JPetstore does use the DAO Framework. You will notice the
BaseSqlMapDao extends SqlMapDaoTemplate and a dao.xml is located in
the com.ibatis.jpetstore.persistence package.

In short:
IBatis DAO Framework simplifies the usage of the DAO pattern.
IBatis SqlMaps simplify the use of jdbc.

Brandon

On Wed, 29 Dec 2004 16:38:26 -0600, Albert L. Sapp <as...@uiuc.edu> wrote:
> 1.  Can someone explain to me how the DAO framework enhances the use of SQL
> Maps framework or is the DAO framework a replacement for SQL Maps
> framework?  Both of them seem to be used as transaction managers.  All I am
> wanting to do is some transaction processing against a Oracle database
> using a JDBC connection and SQL statements.
> 
> 2.  When I look at the source code files for JPetStore, I can seem to
> follow what is happening.  It seems to only use SQL Maps.  Am I correct?
> 
> Once I know what the relationship between the two is, I may be able to
> figure out how to complete the project I am working on.  Right now, none of
> our dao.xml or sql-maps.xml files look very close to the pet store samples.
> 
> Thanks,
> 
> Al
> 
>

Re: SQL Maps and/or DAO

Posted by "Albert L. Sapp" <as...@uiuc.edu>.
Thanks to everyone who responded.  The explanations have helped.

I am trying to compare how JPetStore is setup in relation to our 
application.  We have broken our application up into functional business 
units.  It looks like each unit has a domain and persistance section, but I 
have not matched up where the presentation and service sections are.  Our 
struts and web sections seem to be organized more along the same line as 
the example.  I may need to reorganize the rest along the same lines so I 
can make sure I am getting done what needs to be done.

The application seems to work fine when doing a standalone insert, update, 
delete and query.  It does not work when we try to do more than one such 
operation with commit/rollback being dependant on all operations succeeding 
before commit.  We use startTransaction, commitTransaction and 
endTransaction in both cases, but rollback on failure does not seem to occur.

I found I need to turn off the autocommit in the Oracle JDBC driver and I 
think I have found where to do that.  It will turn it off for the entire 
application, however.  I am hoping that this corrects the problem I am having.

Anyway, I want to thank you all again for the point in the right direction.

Al

At 12:00 PM 12/30/2004, Clinton Begin wrote:
>Hi Albert,
>
>1) DAO is an abstraction layer that sits between your persistence
>solution and your service/domain layer.  It serves to maintain a
>consistent API and transaction management facility to all of the
>higher layers (like service and domain).  Without it, you will end up
>with various different types of artifacts from your persistence
>solution (like Session, or Connection) all mixed together.  You'll
>also find yourself more tied to your persistence solution.  One point
>about DAO -- don't be afraid to write your own DAO!  iBATIS is one
>implementation, but of anything else in iBATIS, DAO is the part that's
>is often best written for your specific application and customized to
>your needs.
>
>2) The answer to this depends on which version of JPetStore you're
>using.  JPetStore version 4 uses DAO 2.0 and SQL Maps 2.0.
>
>Cheers,
>Clinton
>
>
>On Wed, 29 Dec 2004 17:05:58 -0800 (PST), Daniel H. F. e Silva
><dh...@yahoo.com> wrote:
> > Hi Albert,
> >
> >   Well, i'm not one of the masters of iBATIS but i'm going to try to 
> answer your questions.
> > Brandon, Larry and Clinton, please, you can slap me if i say something 
> stupid. ;-)
> >
> >   1. DAO framework and SQL Maps framework are different things. You can 
> use both to leverage your
> > application design, but, you can use anyone by itself. For example, i 
> wrote once an application
> > that used only DAO framework because i was not fetching data from a 
> relational database but from
> > an LDAP data source. Doing so, DAO framework gave me a invaluable 
> feature: decoupling. No matter
> > from where i was fetching data, my application would work the same way 
> ever.
> >
> >   2. Clinton is the right guy to answer this question. But, as far as i 
> know, JPetsore uses DAO
> > framework too. But i can be wrong (with a large probability ;-) ).
> >
> >   There is a simple tutorial that can help to make some points clearer 
> to you. It was written by a
> > great guy and friend of Brandon, Larry and Clinton. His name is Rick. 
> Look it here:
> > http://www.reumann.net/struts/main.do. Pick the Struts with iBATIS 
> tutorial.
> >
> >   That was my 2 cents!
> >
> > Cheers,
> >  Daniel Silva.
> >
> > --- "Albert L. Sapp" <as...@uiuc.edu> wrote:
> >
> > > 1.  Can someone explain to me how the DAO framework enhances the use 
> of SQL
> > > Maps framework or is the DAO framework a replacement for SQL Maps
> > > framework?  Both of them seem to be used as transaction 
> managers.  All I am
> > > wanting to do is some transaction processing against a Oracle database
> > > using a JDBC connection and SQL statements.
> > >
> > > 2.  When I look at the source code files for JPetStore, I can seem to
> > > follow what is happening.  It seems to only use SQL Maps.  Am I correct?
> > >
> > > Once I know what the relationship between the two is, I may be able to
> > > figure out how to complete the project I am working on.  Right now, 
> none of
> > > our dao.xml or sql-maps.xml files look very close to the pet store 
> samples.
> > >
> > > Thanks,
> > >
> > > Al
> > >
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - now with 250MB free storage. Learn more.
> > http://info.mail.yahoo.com/mail_250
> >


Re: SQL Maps and/or DAO

Posted by Clinton Begin <cl...@gmail.com>.
Hi Albert,

1) DAO is an abstraction layer that sits between your persistence
solution and your service/domain layer.  It serves to maintain a
consistent API and transaction management facility to all of the
higher layers (like service and domain).  Without it, you will end up
with various different types of artifacts from your persistence
solution (like Session, or Connection) all mixed together.  You'll
also find yourself more tied to your persistence solution.  One point
about DAO -- don't be afraid to write your own DAO!  iBATIS is one
implementation, but of anything else in iBATIS, DAO is the part that's
is often best written for your specific application and customized to
your needs.

2) The answer to this depends on which version of JPetStore you're
using.  JPetStore version 4 uses DAO 2.0 and SQL Maps 2.0.

Cheers,
Clinton


On Wed, 29 Dec 2004 17:05:58 -0800 (PST), Daniel H. F. e Silva
<dh...@yahoo.com> wrote:
> Hi Albert,
> 
>   Well, i'm not one of the masters of iBATIS but i'm going to try to answer your questions.
> Brandon, Larry and Clinton, please, you can slap me if i say something stupid. ;-)
> 
>   1. DAO framework and SQL Maps framework are different things. You can use both to leverage your
> application design, but, you can use anyone by itself. For example, i wrote once an application
> that used only DAO framework because i was not fetching data from a relational database but from
> an LDAP data source. Doing so, DAO framework gave me a invaluable feature: decoupling. No matter
> from where i was fetching data, my application would work the same way ever.
> 
>   2. Clinton is the right guy to answer this question. But, as far as i know, JPetsore uses DAO
> framework too. But i can be wrong (with a large probability ;-) ).
> 
>   There is a simple tutorial that can help to make some points clearer to you. It was written by a
> great guy and friend of Brandon, Larry and Clinton. His name is Rick. Look it here:
> http://www.reumann.net/struts/main.do. Pick the Struts with iBATIS tutorial.
> 
>   That was my 2 cents!
> 
> Cheers,
>  Daniel Silva.
> 
> --- "Albert L. Sapp" <as...@uiuc.edu> wrote:
> 
> > 1.  Can someone explain to me how the DAO framework enhances the use of SQL
> > Maps framework or is the DAO framework a replacement for SQL Maps
> > framework?  Both of them seem to be used as transaction managers.  All I am
> > wanting to do is some transaction processing against a Oracle database
> > using a JDBC connection and SQL statements.
> >
> > 2.  When I look at the source code files for JPetStore, I can seem to
> > follow what is happening.  It seems to only use SQL Maps.  Am I correct?
> >
> > Once I know what the relationship between the two is, I may be able to
> > figure out how to complete the project I am working on.  Right now, none of
> > our dao.xml or sql-maps.xml files look very close to the pet store samples.
> >
> > Thanks,
> >
> > Al
> >
> >
> 
>                 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - now with 250MB free storage. Learn more.
> http://info.mail.yahoo.com/mail_250
>

Re: SQL Maps and/or DAO

Posted by "Daniel H. F. e Silva" <dh...@yahoo.com>.
Hi Albert,

  Well, i'm not one of the masters of iBATIS but i'm going to try to answer your questions.
Brandon, Larry and Clinton, please, you can slap me if i say something stupid. ;-)
  
  1. DAO framework and SQL Maps framework are different things. You can use both to leverage your
application design, but, you can use anyone by itself. For example, i wrote once an application
that used only DAO framework because i was not fetching data from a relational database but from
an LDAP data source. Doing so, DAO framework gave me a invaluable feature: decoupling. No matter
from where i was fetching data, my application would work the same way ever.

  2. Clinton is the right guy to answer this question. But, as far as i know, JPetsore uses DAO
framework too. But i can be wrong (with a large probability ;-) ).

  There is a simple tutorial that can help to make some points clearer to you. It was written by a
great guy and friend of Brandon, Larry and Clinton. His name is Rick. Look it here:
http://www.reumann.net/struts/main.do. Pick the Struts with iBATIS tutorial.

  That was my 2 cents! 

Cheers,
 Daniel Silva.

--- "Albert L. Sapp" <as...@uiuc.edu> wrote:

> 1.  Can someone explain to me how the DAO framework enhances the use of SQL 
> Maps framework or is the DAO framework a replacement for SQL Maps 
> framework?  Both of them seem to be used as transaction managers.  All I am 
> wanting to do is some transaction processing against a Oracle database 
> using a JDBC connection and SQL statements.
> 
> 2.  When I look at the source code files for JPetStore, I can seem to 
> follow what is happening.  It seems to only use SQL Maps.  Am I correct?
> 
> Once I know what the relationship between the two is, I may be able to 
> figure out how to complete the project I am working on.  Right now, none of 
> our dao.xml or sql-maps.xml files look very close to the pet store samples.
> 
> Thanks,
> 
> Al
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250