Entity bean design and construction best practices

In this example, we introduced a couple of best practices that we want to summarize:

  • Use of local interfaces— We modeled the entity beans to only be used within the JVM from other processes, in this case, other session beans. Therefore, we chose to define local instead of remote interfaces for our beans. This allowed us to have faster access to the entity bean.

  • Do not promote the primary key setters/getters to component interface— Although we could have put the setters/getters into the component interface, we chose not to. Invoking the setCustomerID would have resulted in a runtime error, and we have other means to get the primary key that do not require the getter method.

  • Use of CMP over BMP— ...

Get EJB 2.0 Development with WebSphere Studio Application Developer 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.