We are, of course, free to add additional methods to the generated session beans.
For example, sometimes it is necessary to add a method to find all entities that
meet specific criteria, such as finding all customers with the same last name.
One disadvantage of adding methods to the generated session beans
is that, if for any reason they need to be regenerated, we will lose our
custom methods and they will need to be added again. In order to avoid
this situation, it is a good idea to extend the generated session beans and
add additional methods in the child classes; this will prevent our methods
from being "wiped out" if we ever need to regenerate our session beans.
In this chapter, we gave an introduction to session beans, and explained how
NetBeans can help us speed up session bean development.
We covered how EJBs in general, and session beans in particular, allow us to easily
implement transaction strategies in our enterprise applications. We also covered
how we can implement AOP with session beans via interceptors. Additionally, we
discussed how session beans can have one of their methods invoked periodically
by the EJB container by taking advantage of the EJB Timer service. Lastly, we
covered how NetBeans can help speed up the implementation of the data access
layer of our applications by generating session beans implementing the Data Access
Object (DAO) design pattern automatically.