You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2006/01/27 17:40:20 UTC

design question

For all the tables in the JSP, I am using displaytag.


For each row in the table I created an Object.

I am creating instances of this Object and making a List which is getting 
displayed in the JSP.

I was told that instead of creating Object and creating instances, one can 
directly use the result set got from the DB and iterate thru it to fill the 
tables.

Which one is more efficient way to do? Is the second approach better? if so 
why?

Thanks.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Re: [OT] Re: design question

Posted by fea jabi <zy...@hotmail.com>.
thankyou, for all your valuable responces.


>From: Dave Newton <ne...@pingsite.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: [OT] Re: design question
>Date: Tue, 31 Jan 2006 10:13:24 -0500
>
>fea jabi wrote:
> > you have mentioned that
> >
> > "You're going to have an object in memory no matter what"
> >
> > If we are using Resultset how/when is the Object getting created? I
> > was under the impression that it will get the data directly from the DB.
>Uh... a ResultSet is an object.
> >> You're going to have an object in memory no matter what. In most cases
> >> DB connections are a more limited resource than memory. Besides, once
> >> the ResultSet is translated into a DTO, it is free for GC anyway, so
> >> you've really only lost the conversion time, which is worth it IMO.
> > what are these DTO, GC and IMO?
>Data Transfer Object, Garbage Collection, In My Opinion.
> > I do remember reading somewhere that if this approach is used then
> > we'll be breaking the MVC architecture.
> > any reference links for this?
>Nope. I'd bet Google could help you out here, though.
>
>I'm not sure I'd say using a ResultSet directly breaks MVC... while I'm
>not sure I'd call a ResultSet a "real" DTO, that aspect of it doesn't
>relly enter into the MVC equation. MVC has more to do with separation of
>responsibilities between the business model, presentation model, and how
>control is delegated. (That was _not_ a good explanation.)
>
>Dave
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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


Re: [OT] Re: design question

Posted by Dave Newton <ne...@pingsite.com>.
fea jabi wrote:
> you have mentioned that
>
> "You're going to have an object in memory no matter what"
>
> If we are using Resultset how/when is the Object getting created? I
> was under the impression that it will get the data directly from the DB.
Uh... a ResultSet is an object.
>> You're going to have an object in memory no matter what. In most cases
>> DB connections are a more limited resource than memory. Besides, once
>> the ResultSet is translated into a DTO, it is free for GC anyway, so
>> you've really only lost the conversion time, which is worth it IMO.
> what are these DTO, GC and IMO?
Data Transfer Object, Garbage Collection, In My Opinion.
> I do remember reading somewhere that if this approach is used then
> we'll be breaking the MVC architecture.
> any reference links for this?
Nope. I'd bet Google could help you out here, though.

I'm not sure I'd say using a ResultSet directly breaks MVC... while I'm
not sure I'd call a ResultSet a "real" DTO, that aspect of it doesn't
relly enter into the MVC equation. MVC has more to do with separation of
responsibilities between the business model, presentation model, and how
control is delegated. (That was _not_ a good explanation.)

Dave



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


Re: [OT] Re: design question

Posted by fea jabi <zy...@hotmail.com>.
you have mentioned that

"You're going to have an object in memory no matter what"

If we are using Resultset how/when is the Object getting created? I was 
under the impression that it will get the data directly from the DB.

what are these DTO, GC and IMO?

I do remember reading somewhere that if this approach is used then we'll be 
breaking the MVC architecture.

any reference links for this?

Thanks.


>From: Dave Newton <ne...@pingsite.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: [OT] Re: design question
>Date: Mon, 30 Jan 2006 15:56:31 -0500
>
>fea jabi wrote:
> > But as I mentioned earliar I am creating an object which I am planning
> > to instanciate for each row of data. When I told about this to my team
> > they were concerned about the objects being in memory and advised to
> > use the resultset directly. In the sessionbean probably we can create
> > these rowobjects before it's sent to the webserver.
>You're going to have an object in memory no matter what. In most cases
>DB connections are a more limited resource than memory. Besides, once
>the ResultSet is translated into a DTO, it is free for GC anyway, so
>you've really only lost the conversion time, which is worth it IMO.
>
>I think that using a POJO (or POJO+) for the DTO more than pays for the
>conversion time with easier code, generally more robust code, etc.
>
>Dave
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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


Re: [OT] Re: design question

Posted by Dave Newton <ne...@pingsite.com>.
fea jabi wrote:
> But as I mentioned earliar I am creating an object which I am planning
> to instanciate for each row of data. When I told about this to my team
> they were concerned about the objects being in memory and advised to
> use the resultset directly. In the sessionbean probably we can create
> these rowobjects before it's sent to the webserver.
You're going to have an object in memory no matter what. In most cases
DB connections are a more limited resource than memory. Besides, once
the ResultSet is translated into a DTO, it is free for GC anyway, so
you've really only lost the conversion time, which is worth it IMO.

I think that using a POJO (or POJO+) for the DTO more than pays for the
conversion time with easier code, generally more robust code, etc.

Dave



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


RE: [OT] Re: design question

Posted by fea jabi <zy...@hotmail.com>.
Thanks for your responses.

I am currently not interacting with DB. Will ofcourse be soon.

But as I mentioned earliar I am creating an object which I am planning to 
instanciate for each row of data. When I told about this to my team they 
were concerned about the objects being in memory and advised to use the 
resultset directly. In the sessionbean probably we can create these 
rowobjects before it's sent to the webserver.

from your advise using resultset is not a good idea. I was looking for these 
kind of answers.

Thanks again.


>From: Dave Newton <ne...@pingsite.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: [OT] Re: design question
>Date: Mon, 30 Jan 2006 11:42:10 -0500
>
>fea jabi wrote:
> > can anyone help me understand this?
>Don't know.
> >> I am creating instances of this Object and making a List which is
> >> getting displayed in the JSP.
> >>
> >> I was told that instead of creating Object and creating instances,
> >> one can directly use the result set got from the DB and iterate thru
> >> it to fill the tables.
> >>
> >> Which one is more efficient way to do? Is the second approach better?
> >> if so why?
>Efficiency-wise? Depends on where you want your efficiency. You can use
>a ResultSet directly, but you must keep the statement (and connection?)
>open while using it, which might lead to number-of-connection issues.
>
>In general, I have pretty strong feelings against using "raw" ResultSets
>despite the overhead of copying data... anything other than raw JDBC
>will see the same behavior whether it's a full ORM or something as
>simple as a RowSetDynaClass (from Jakarta BeanUtils).
>
>Of course, I have no idea how you're currently interacting with the DB,
>so it's hard to say.
>
>Dave
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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


[OT] Re: design question

Posted by Dave Newton <ne...@pingsite.com>.
fea jabi wrote:
> can anyone help me understand this? 
Don't know.
>> I am creating instances of this Object and making a List which is
>> getting displayed in the JSP.
>>
>> I was told that instead of creating Object and creating instances,
>> one can directly use the result set got from the DB and iterate thru
>> it to fill the tables.
>>
>> Which one is more efficient way to do? Is the second approach better?
>> if so why?
Efficiency-wise? Depends on where you want your efficiency. You can use
a ResultSet directly, but you must keep the statement (and connection?)
open while using it, which might lead to number-of-connection issues.

In general, I have pretty strong feelings against using "raw" ResultSets
despite the overhead of copying data... anything other than raw JDBC
will see the same behavior whether it's a full ORM or something as
simple as a RowSetDynaClass (from Jakarta BeanUtils).

Of course, I have no idea how you're currently interacting with the DB,
so it's hard to say.

Dave



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


RE: design question

Posted by fea jabi <zy...@hotmail.com>.
can anyone help me understand this? Thanks.


>From: "fea jabi" <zy...@hotmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: user@struts.apache.org
>Subject: design question
>Date: Fri, 27 Jan 2006 11:40:20 -0500
>
>For all the tables in the JSP, I am using displaytag.
>
>
>For each row in the table I created an Object.
>
>I am creating instances of this Object and making a List which is getting 
>displayed in the JSP.
>
>I was told that instead of creating Object and creating instances, one can 
>directly use the result set got from the DB and iterate thru it to fill the 
>tables.
>
>Which one is more efficient way to do? Is the second approach better? if so 
>why?
>
>Thanks.
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today - it's FREE! 
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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