This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB Design With Value Objects  RSS feed

Greg Nudelman
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear EJB Gurus:
I have an EJB system with a HashMap-driven customization interface on the web-tier (That is I ultimately need to persent a HashMap of Strings values to my JSP for display).
Because of the badly coded EJBs, I had a need to create a fairly large (100 attributes, representing 5 DB tables) value object (VO) to validate and massage the complete incoming data. I then use this VO to set my Entity EJBs under the wrapping of a Session EJB. This leaves me a with a large VO on the EJB server and a HashMap that needs to be displayed on the client. Incoming data is of course unformated, and the dat that needs to be displayed from the HashMap needs to be formated. the formating logic is inside the VO.
incoming -> display
"1" -> "Books"
"1000" -> $1,000.00"

I have the following choices (assuming success of all operations):
1) Communicate via VOs:
Collect data, create a VO, and validate, all on the web tier. Then pass this valid VO to the EJB tier to save in the DB. [Optional: Return a new VO to the web tier that resulted from integrating the data.]
Get a VO from the EJB, then use this VO on the Web tier to produce a formated display view HashMap and display it.
2) Communicate via HashMaps:
Collect data in the HashMap structure on the web tier, then pass that structure without validation to the EJB tier. On the EJB tier: construct VO, validate, pass VO to the Entity Beans, and save to DB. Then use this same VO to produce a formated display view HashMap and send it to the Web tier for display.
I have a "Core J2EE Patterns" book, but it describes VOs that are very light and just hold the data (So in my case HashMap acts like this). VOs do not massage data, translate it or validate it, nor present it for display. This is what the EJB Business methods supposed to do.
I want this to be squeaky-clean since I'm re-doing a lot of bad code already. Any thoughts would be greatly appreciated.
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO VO are made to avoid the expensive remote calls. Also VO must be handled carefully since they have to be insync with the beans so that they dont become dirty.
If the VO is very big (megs?) IMO i dont think it may be worth to use VO to begin with ,considering the network bandwith
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!