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
[EMAIL PROTECTED]
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, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> 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:[EMAIL PROTECTED]
>Verzonden: maandag, maart 3, 2008 02:12 AM
>Aan: [email protected]
>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, [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
>>
>>
>>
>>
>>
>