O'Reilly logo

Java™ Web Services Unleashed by Mark Wutka, Joseph Weber, Arthur Ryman, K. Scott Morrison, Benoît Marchal, Matthias Kloppmann, Steven Haines, Darren Govoni, Francisco Curbera, Frank Cohen, Robert Brunner

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

Entity Beans

Although the stock trading application uses a number of entity beans, the entity bean code is very simple. All the beans use container-managed persistence (CMP), so they don't worry about persisting themselves in the database. The one difficulty you often find with CMP is that it doesn't handle automatically-generated keys (sequenced keys) very well. You usually must generate the sequenced key yourself. Listing 21.6 shows a simple base class that generates a sequenced key automatically. If you subclass this class, you don't have to write any special code to generate your keys.

Listing 21.6. Source Code for AutoKeyEJB.java
 package jwsunleashed.trading.ejb; import java.rmi.*; import java.util.*; import javax.ejb.*; import java.sql.*; ...

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