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.
package jwsunleashed.trading.ejb; import java.rmi.*; import java.util.*; import javax.ejb.*; import java.sql.*; ...