Chapter 5. Advanced Entities
In this chapter, we’ll dig into some more interesting entity bean topics. I’ll start by looking at how entity beans can and should abstract database IDs and sequences from business-oriented clients. You’ll see how session beans can be used for these sorts of tasks, learn about database access through JDBC in beans, and put all these pieces into a coherent whole. From there I’ll move on to discussing entity bean value objects, serialization of these objects, and decreasing RMI traffic.
I’ll also discuss when to use container-managed persistence (CMP) and when to use bean-managed persistence (BMP). This leads you from accessing the database to accessing the directory server set up for usernames and authentication data. I’ll also cover the variety of ways you can access a directory server. At this point, the Java Naming and Directory Interface (JNDI) will enter the picture, too. By the end of this chapter, you’ll have several new entity beans, a session bean, a more advanced Office bean, and a thorough understanding of entity bean architecture.
IDs, Sequences, and CMP
The most common problem in working with entity beans is dealing with primary keys. The underlying principle is that EJB components should represent business objects and business entities. In other words, if something isn’t used in the business of an application, it shouldn’t be visible to the bean developer. What that means in terms of the entity beans so far is that you need to hide the details ...
Get Building Java Enterprise Applications 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.