• Post Reply Bookmark Topic Watch Topic
  • New Topic

how we should use DTO when it is a Master details , Master table DTO

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thank you for reading my post.
A master details scenario the master record address some details record like a invoice and its lines (items)
now my question is :
should the invoice DTO contains all items ?
or it should just contain invoice details without its lines (items)


Thank you
 
Scott Selikoff
author
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really depends on your business requirements. Most external DTOs, the kinds that are sent to/from clients for example, are usually serializable and as such are usually based on simple data types like java primitives, wrappers, and arrays.

What are the types of objects you'd like to pass around? And how will the data be used? Is it attached to database instances?
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raminaa,


Hi
Thank you for reading my post.
A master details scenario the master record address some details record like a invoice and its lines (items)
now my question is :
should the invoice DTO contains all items ?
or it should just contain invoice details without its lines (items)


There are two standard posible scenarios to consider: lazy or eagrly loading. Entity EJBs for example default to lazy loading (remember the n+1 select problem with entity ejbs). In this scenario you'll return only the invoice's details and references to all included items only (in an attempt to reduce the network traffic). This approach is efficient when clients loop through the invoices and display the invoice details along with at most the references to all its items (presenting them in a tabular format like a table). A click on the invoice record should result in one more jdbc call in order to display detailed informations about each invoice. If you have such usecases then you can use this approach.
The more efficient eagerly loading would return the invoice along with all its items at once. The obvious advantage is that you don't need any subsequent jdbc calls for displaying details\ed information about each item. The drawback of course is that you'll return the data in one huge bulk consuming more network bandwidth. As for comparison I'll tell you that entity ejbs could be configure to use eagarly loading as well (using vendor specific settings) and this should usually improve the overall performances quite a bit.
Regards.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!