You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Nathan Maves <Na...@Sun.COM> on 2005/02/16 18:04:27 UTC

Where to catch DaoException?

Just curious what the best practices about this are.  And since the 
DaoExcpetion is now a runtime you have to explicitly put your try {} 
catch {} blocks somewhere right :)


Here is my setup

Struts Actions (Presentation)
Service Layer (Business Logic) I assume here :)
Dao layer	(Data Access Layer)


Nathan


queryForMap from resultMap

Posted by Anad Fida <am...@gmail.com>.
I have a Domain Object as following,

public class Account {

    private long accountKey;
    private String accountName;
    private String userName;
    private Date lastUpdateDate;

   // Holds account attribute name - values
    private Map accountAttributes;
 
   // Setters/Getters........
   
}

I have accounts, attributes, account_attributes tables, you know the 
usual relationships. My problem is in order to get the Account and for 
each account, I need to get  its attribute map.

One option is to get all the accounts and then for each account i get 
its attributes as name, value pair using "queryForMap("queryID", 
account.getKey(), "Name", "Value"). But I have around 50, 000 accounts 
and for each account I have to run this extra query so could end up 
running 50, 001 queries.

I was hoping that I could use this queryForMap from accounts resultMap as
<resultMap id="getAccounts">
.....
<result property="accountAttributes" column="accountKey" 
select="getAccountAttributeMap">,
....
</resultMap>

but i want to specify the property for key and property for value, for 
this "getAccountAttributeMap".  I am not sure how to do that from SqlMap?

Any help would be really appreciated.

Amad


Re: Where to catch DaoException?

Posted by Brandon Goodin <br...@gmail.com>.
I only catch exception if i need to clean something up or if i can
recover from it. Otherwise, let em rip. Between my Presentation layer
and my service layer i throw RuntimeExceptions. I do logging of
exceptions at the highest point of my application. If i wanted to
provide a pretty screen for clients instead of a stack trace i'd use
the struts layer to catch and log the exception then give the user a
kinder gentler error message. You can also use tomcat to accomplish
that.

Brandon


On Wed, 16 Feb 2005 11:39:27 -0600, friendVU admin
<ma...@friendvu.com> wrote:
> 
> In Struts.... I would catch the action where it happens and keep
> rethrowing it to the container.
> This way web.xml error page can display a nicley formated message.
> 
> .V
> 
> Nathan Maves wrote:
> 
> > Just curious what the best practices about this are.  And since the
> > DaoExcpetion is now a runtime you have to explicitly put your try {}
> > catch {} blocks somewhere right :)
> >
> >
> > Here is my setup
> >
> > Struts Actions (Presentation)
> > Service Layer (Business Logic) I assume here :)
> > Dao layer    (Data Access Layer)
> >
> >
> > Nathan
> >
> >
> >
> 
>

Re: Where to catch DaoException?

Posted by friendVU admin <ma...@friendvu.com>.
In Struts.... I would catch the action where it happens and keep 
rethrowing it to the container.
This way web.xml error page can display a nicley formated message.

.V

Nathan Maves wrote:

> Just curious what the best practices about this are.  And since the 
> DaoExcpetion is now a runtime you have to explicitly put your try {} 
> catch {} blocks somewhere right :)
>
>
> Here is my setup
>
> Struts Actions (Presentation)
> Service Layer (Business Logic) I assume here :)
> Dao layer    (Data Access Layer)
>
>
> Nathan
>
>
>