• Post Reply Bookmark Topic Watch Topic
  • New Topic

Coding a getDTO method  RSS feed

 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I code a getDTO method in a client code such as a servlet.
Thankyou for any help.
Cheers Tony
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by TonyCavanagh:
How would I code a getDTO method in a client code such as a servlet.
Thankyou for any help.
Cheers Tony

Tony,
Maybe I'm misunderstanding what you're asking. DTO usually refers to a Data Transfer Object. A Data Transfer Object is frequently used to return data from an EntityBean in one "chunk" as an object instead of calling multiple getters. This reduces the network traffice and makes the application run more efficiently.
You would simply need to design your DTO class and provide your EntityBean with a remote method to return an instance of the DTO object.
Naturally, you'll need to lookup your EJB using JNDI, narrow it, etc.
Regards,
Byron Estes
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Byron
Cheers for replying. So it would be something line this.
I have a DTO AccountDTO;
And a Method
AccountDTO getAccountDTO() and inside the method I would use a JNDI call.
Could I use a generic getADTO, which would take the JNDI variables as parameters and return an object which would then be cast to the correct DTO.
Thanks Tony
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by TonyCavanagh:
Hi Byron
Cheers for replying. So it would be something line this.
I have a DTO AccountDTO;
And a Method
AccountDTO getAccountDTO() and inside the method I would use a JNDI call.
Could I use a generic getADTO, which would take the JNDI variables as parameters and return an object which would then be cast to the correct DTO.
Thanks Tony

Tony,
You could do that but the idea is to separate the data from the object that knows how to get it (i.e. the EntityBean). It's more common to define a simple value object (ADO) which is built by the EntityBean when it's getADO() method is called. The ADO value object is passed back to the caller. The caller now has local access to data and doesn't need to make expensive over the wire calls to access individual elements/fields.
Best,
Byron Estes
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!