File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Guidance needed with an iBatis/servlets app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Guidance needed with an iBatis/servlets app" Watch "Guidance needed with an iBatis/servlets app" New topic
Author

Guidance needed with an iBatis/servlets app

Damian Lundgren
Greenhorn

Joined: Nov 30, 2008
Posts: 1
I realize that this message could be posted in more than one forum but I picked the one that I thought would fit the best. Please do let me know if I should post it somewhere else.

What is the best place to initialize an iBatis SqlMapClient? I am writing a simple (with an emphasis on "simple") web app accessing a database. I want to avoid using the DAO pattern as much as possible. I currently have the SqlMapClient created within an init() method of an InitServlet at the application startup and stored as an attribute of the servlet context. Every servlet retrieves the SqlMapClient attribute at run time and passes it to my "business logic layer" which acts as a "service" layer operating on pojos and does the db access (I don't worry much about my code being coupled with ibatis much). I have a couple of questions related to this:

1) Do you see anything wrong with this approach that might hurt down the road and - if so - what is the approach you would recommend?

2) By passing the SqlMapClient to the "business logic layer" objects, the SqlMapClient doesn't get recreated, right? In other words - once it is initialized during init(), it won't read its XML maps anymore - is this correct?

3) My "business logic layer" consists of simple java classes (e.g. AccountManager with methods such as openAccount(), ChangeAccount(), etc.). What I was hoping to do instead of passing the sqlMap to every one of those objects (like AccountManager) is to have it available globally (singleton pattern?) so that each method can use it but I am not sure how to go about that. Any ideas? My understanding is that SqlMapClient is thread-safe.

Thanks in advance for any and all feedback. Cheers!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Guidance needed with an iBatis/servlets app
 
Similar Threads
Web app design confusion
Excess functionality?
Tomcat 5.5 SEVERE: Error listenerStart
Why to use Ibatis DAO pattern
Architecture of presentation and business layer