O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating View Objects

One of the most common patterns you see in three-tiered applications is the use of view objects. Remember, you want to reduce the number of calls you make from the client to the EJB container. If you need to retrieve a large number of fields from an EJB, either a session bean or an entity bean, you want to retrieve the values with a single method call.

You package all the values you want into a view class, which contains all the data items you want to retrieve. For example, Listing 12.1 shows a PersonView class holding all the data for a Person bean.

Code Listing 12.1. Source Code for PersonView.java
 package usingj2ee.addressbook; public class PersonView implements java.io.Serializable { public String firstName; public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required