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.*; ... |
Get Java™ Web Services Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.