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, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> 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
>
>
>
>
>