ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: iBATIS for swing application
Date Mon, 03 Mar 2008 20:22:19 GMT
I'm tempted to say "trust me, it's better".  But I think it would be
interesting for you to do some reading about it.  This is the classic
question regarding the Singleton design pattern.

Do a google query for "singleton vs static" and you'll get a lot of hits.
Here's a good starting point:

http://www.kamalmeet.com/wordpress/2006/06/22/singleton-vs-static-classes/


The main issues are:

1. Better control of creation
2. Easier to subclass

These may, or may not, matter to you.

Jeff Butler



On Mon, Mar 3, 2008 at 2:12 PM, Pieter Baele <pieter.baele@telenet.be>
wrote:

> What's the benefit of using this factory as a Singleton?
> One of my co-students suggested making all methods static,
> so you can use Factory.getXxxDAO() instead off
> Factory.getInstance.getXxxDAO();
> but I'm not sure about that....
>
>
> Pieter Baele
> pieter.baele@telenet.be
>
> In Microsoft world, you are always one click away from harming yourself™
> - trustnoguy
>
> On 03 Mar 2008, at 14:55, Jeff Butler wrote:
>
> > The SVN version is very stable and has a few extra features (it now
> > generates countByExample and updateByExample methods) , but the 1.0
> > version should be fine too.  I think you could use either.
> >
> > Jeff Butler
> >
> > On Mon, Mar 3, 2008 at 2:02 AM, pieter.baele@pandora.be <
> pieter.baele@telenet.be
> > > wrote:
> > Jeff,
> >
> > It helps a lot, I didn't knew abator also can generate a generic DAO.
> > Is it recommended to use the svn version?
> >
> > Thx!
> > Pieter
> >
> >
> >
> > >----- Oorspronkelijk bericht -----
> > >Van: Jeff Butler [mailto:jeffgbutler@gmail.com]
> > >Verzonden: maandag, maart 3, 2008 02:12 AM
> > >Aan: user-java@ibatis.apache.org
> > >Onderwerp: [SPAM] Re: iBATIS for swing application
> > >
> > >Here's a way to use the generic DAOs built by Abator (I think this
> > is the
> > >easiest way to do it if you're not using Spring):
> > >
> > >1. Use Abator to generate generic DAOs with the GENERIC-CI DAO
> > generator
> > >2. Write an SqlMapConfig.xml file listing all the SqlMap.xml files
> > generated
> > >by Abator (theres an example in the Abator documentation)
> > >3. Write a Singleton factory for DAOs the DAOs:
> > >
> > >public class DAOFactory {
> > >
> > >  private static DAOFactory instance = new DAOFactory();
> > >  public static DAOFactory getInstance() {
> > >    return instance;
> > >  }
> > >
> > >  private SqlMapClient sqlMap;
> > >  private MyDao myDao;
> > >
> > >  private DAOFactory () {
> > >    String resource = "com/mycompany/SqlMapConfig.xml";
> > >    Reader reader = Resources.getResourceAsReader(resource);
> > >    sqlMap = SqlMapClientBuilder.buildSqlMap(reader);
> > >  }
> > >
> > >  public MyDao getMyDao() {
> > >    if (myDao == null) {
> > >      myDao = new MyDaoImpl(sqlMap);
> > >    }
> > >    return myDao;
> > >  }
> > >}
> > >
> > >You can repeat the MyDao method for every DAO generated by Abator.
> > >
> > >3. Use this factory anywhere in your Swing app like this:
> > >
> > >MyDao myDao = DAOFactory.getInstance().getMyDao();
> > >myDao.insert(myObject);
> > >
> > >etc.
> > >
> > >Hope that helps -
> > >
> > >Jeff Butler
> > >
> > >
> > >
> > >
> > >
> > >
> > >On Sun, Mar 2, 2008 at 1:09 PM, pieter.baele@pandora.be <
> > >pieter.baele@telenet.be> wrote:
> > >
> > >> Hello,
> > >>
> > >> I am a student (college university) working on a part of a
> > fictive project
> > >> management software system.
> > >>
> > >> We received a database dll scheme, so Hibernate was not really an
> > option.
> > >> It's also a very short project (8 weeks) so iBATIS is definitely
> > a better
> > >> solution.
> > >> (shorter learning curve)
> > >>
> > >> I've bought iBATIS in action and generated Java Beans and sqlmaps
> > with
> > >> abator.
> > >>
> > >> But now I am stuck. I need some sort of Factory/Facade/Controller
> > for the
> > >> sqlMaps, but how to code these?
> > >> It's a desktop app, so isn't the (Spring) DAO overkill??? (I also
> > don't
> > >> have enough time...)
> > >> Is it necessary to use a DAO? Is the iBATIS DAO out-of-date
> > because it
> > >> isn't under development anymore?
> > >>
> > >> I don't like the MVC solution we've seen in the Java lessons -
> > manually
> > >> writing a Connection class, and Mapper classes (Prepared and
> > Callable
> > >> statements)
> > >> ...but I also don't really know how to fill in the gap between
> > Swing
> > >> (view) and the sqlmaps + beans...
> > >>
> > >> Any help is greatly appreciated.
> > >>
> > >> A desperate ;-) student
> > >> Greeting, PieterB
> > >>
> > >>
> > >>
> > >>
> > >>
> > >
> >
> >
> >
>
>

Mime
View raw message