|
From: <tri...@tr...> - 2003-07-12 14:50:01
|
Jean-Pierre,
Could you not do this without modifying the JDBC layer? Maybe declare a
UserContext in the custom class and set that via a bean setter.
Something like:
public class SpringQuery extends MappingSqlQuery {
private UserContext userContext;
public SpringQuery(DataSource ds) {
super(ds, "select col1, col2 from table");
compile();
}
protected Object mapRow(ResultSet rs, int rownum) throws SQLException {
....
if (userContext.getLocale().equals("xxx"))
....
....
}
public setUserContext(UserContext uc) {
userContext = uc;
}
}
Thomas
> What I used also in the past is letting the DAO create a 'data-layer' list
> and after that in business layer, iterate the list to replace data-layer
> elements by business-layer ones knowing the contextual information.
>
> This is certainly a better school-approach, but has clearly a performance
> drawback.
>
> Letting rowmap being able to create definitive objects (indeed having a user
> defined contextual info), seems to me, for now, a better solution.
>
> Jean-Pierre
>
> ---------- Initial Header -----------
>
> From : spr...@li...
> To : "rod.johnson" <rod...@in...>
> Cc : "trisberg" <tri...@tr...>,"kk"
> <kk...@kk...>,"springframework-developer"
> <spr...@li...>
> Date : Sat, 12 Jul 2003 12:05:19 +0200
> Subject : [Springframework-developer] Re: [Springframework-developer] Locale
> in rowmap?
>
> Hi Ken, Thomas, Rod,
>
> It seems be a general miscomprehension.
>
> 1) I have no intend to put any dependency between WEB and JDBC.
> My request is only at being able to add an optional 'Object' supplemental
> attribute in execute method. The intend of this attribute is simply to be
> passed on rowmap.
>
> 2) Why cannot this object be passed simply on the current methods?
> Just because JDBC has nothing to do with. It is only for rowmap method as
> this method is responsible for creating (business) objects.
>
> 3) Typical example:
> Searching adresses.
>
> a)Consider the searched adresses are not localized on the database and
> contain a country information.
>
> b)The database contain only the country code of the address.
>
> c)With this country code is read from the database, the rowmap method will
> have to create a Country Object to put in the Address one. This Country
> object will have a name property matching with the current user to serve and
> has nothing to do with the JDBC record.
>
> For creating the correct Country Object, rowmap has to know the Locale to
> serve. In this case the new 'Object' parameter would be filled with the User
> Locale and casted so in rowmap. But in others cases, it could be another
> information as the Locale.
>
> The main need is:
> ROWMAP IS RESPONSIBLE FOR CREATING OBJECTS AND FOR THIS IT CAN HAVE TO KNOW
> OTHER INFORMATION AS JUST THESE READ IN THE DATABASE.
>
> This other information can be just right during the 'execution' call and
> cannot be in this case an instance variable.
>
>
> Regards,
> Jean-Pierre
>
> ---------- Initial Header -----------
>
> From : "Rod Johnson" <rod...@in...>
> To : <tri...@tr...>, "Ken Krebs" <kk...@kk...>
> Cc : "JP Pawlak" <jp....@ti...>,
> "'springframework-developer'"
> <spr...@li...>
> Date : Thu, 10 Jul 2003 17:55:12 +0100
> Subject : Re: [Springframework-developer] Locale in rowmap?
>
> > I would agree with Ken here - we must avoid any dependencies between the
> JDBC
> > framework and the Web framework.
>
> +1. I know of several companies in the UK using JDBC only at this point.
> It's a great route in for Spring.
>
>
>
>
> ********** L'ADSL A 20 EUR/MOIS**********
> Tiscali propose l'ADSL le moins cher du marché : 20 EUR/mois et le modem ADSL
> offert !
> Pour profiter de cette offre exceptionnelle, cliquez ici :
> http://register.tiscali.fr/adsl/
> Offre soumise à conditions.
>
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Parasoft
> Error proof Web apps, automate testing & more.
> Download & eval WebKing and get a free book.
> www.parasoft.com/bulletproofapps1
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
> ********** L'ADSL A 20 EUR/MOIS**********
> Tiscali propose l'ADSL le moins cher du marché : 20 EUR/mois et le modem ADSL
> offert !
> Pour profiter de cette offre exceptionnelle, cliquez ici :
> http://register.tiscali.fr/adsl/
> Offre soumise à conditions.
>
>
>
|