You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andy Cheng <an...@pos.st> on 2003/07/02 18:55:52 UTC

Struts + iBatis Database Layer

Hi! All
Basically I have made the ibatis and struts examples working, and I can
build some simple apps with both.  However, I do not really know how to
link both of them together.  The current solution (I think is rather
stupid) is to get an instance of the sqlMap by calling the sqlMap =
SqlMapConfigExample.getConfiguredSqlMap()  (quoted from the ibatis
example), and then use that instance in doing other action like delete,
or returning lists for display in the view (jsp files).  

This is done by action classes creating an instance of a special class
e.g. DBAccess when the action class is initialized. So,

Jsp --> control --> action --(init)instantiate--> DBAccess
--instantiate--> sqlMap --> database --> List of beans --> jsp (display)

However, can I have a single instance of sqlMap for a session?  How can
I do it?  An example would be a very big step for me.  

Thanks, and sorry for the English as well as very possible use of bad
keywords...

Andy 



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Struts + iBatis Database Layer

Posted by Vic Cekvenich <vi...@baseBeans.com>.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/bPproj/src/war/com/baseBeans/scaFfoldingXpress/base/util/DAOIBaseHelper.java

Andy Cheng wrote:

>Hi! All
>Basically I have made the ibatis and struts examples working, and I can
>build some simple apps with both.  However, I do not really know how to
>link both of them together.  The current solution (I think is rather
>stupid) is to get an instance of the sqlMap by calling the sqlMap =
>SqlMapConfigExample.getConfiguredSqlMap()  (quoted from the ibatis
>example), and then use that instance in doing other action like delete,
>or returning lists for display in the view (jsp files).  
>
>This is done by action classes creating an instance of a special class
>e.g. DBAccess when the action class is initialized. So,
>
>Jsp --> control --> action --(init)instantiate--> DBAccess
>--instantiate--> sqlMap --> database --> List of beans --> jsp (display)
>
>However, can I have a single instance of sqlMap for a session?  How can
>I do it?  An example would be a very big step for me.  
>
>Thanks, and sorry for the English as well as very possible use of bad
>keywords...
>
>Andy 
>  
>

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East.
Open Source <a href ="baseBeans.com">Content Management</a>  basicPortal sofware
Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Struts + iBatis Database Layer

Posted by Brandon Goodin <ma...@phase.ws>.
Here is a link to my BaseDAO that utilizes the Ibatis SqlMap. My plan is to
move this to a singleton that works more like Log4j Logger. This would allow
the SqlMap to be called from a static method. Many people use static methods
in their DAOs to avoid instantiating objects everytime they need to perform
a DAO function. Anyways, that's my .02.

http://www.phase.ws/BaseDAO/

Brandon Goodin


-----Original Message-----
From: Andy Cheng [mailto:andy@pos.st]
Sent: Wednesday, July 02, 2003 10:56 AM
To: struts-user@jakarta.apache.org
Subject: Struts + iBatis Database Layer


Hi! All
Basically I have made the ibatis and struts examples working, and I can
build some simple apps with both.  However, I do not really know how to
link both of them together.  The current solution (I think is rather
stupid) is to get an instance of the sqlMap by calling the sqlMap =
SqlMapConfigExample.getConfiguredSqlMap()  (quoted from the ibatis
example), and then use that instance in doing other action like delete,
or returning lists for display in the view (jsp files).

This is done by action classes creating an instance of a special class
e.g. DBAccess when the action class is initialized. So,

Jsp --> control --> action --(init)instantiate--> DBAccess
--instantiate--> sqlMap --> database --> List of beans --> jsp (display)

However, can I have a single instance of sqlMap for a session?  How can
I do it?  An example would be a very big step for me.

Thanks, and sorry for the English as well as very possible use of bad
keywords...

Andy



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org