I l @ ve RuBoard |
EJB allows for several types of beans: stateless, stateful, and entity. As you progress from stateless to entity, the beans offer more functionality, but at the cost of more required coding. Stateless BeansThe easiest bean type, and the one you'll look at first, is a stateless session bean. Session beans are usually likened to verbs in English; they are used for actions, such as adding something to the database or computing a value. Stateless session beans are throwaway objects. They are maintained in a pool on the EJB server. They keep no state between calls, and they operate strictly on the data passed in via the call. Stateful BeansStateful session beans are allowed to maintain state between calls. By the name , you would think that a stateful bean would be associated directly with a client and that the relationship would be maintained between calls. In fact, you'd be right. Entity BeansThe third kind of bean is an entity bean. An entity bean is very stateful; it represents something permanent, such as a database. When you make a request to an entity bean, you can be actually doing selects, inserts , and updates against a database. This property is called persistence. Two types of entity beans also exist. A bean-managed persistence (BMP) entity bean has code that explicitly tells how to read and write data from the database. It's similar to the code you've written that reads and writes orders from MySQL. The other type of persistent entity bean uses container-managed persistence (CMP). In CMP, a mapping is set up between database columns and bean properties, and the EJB server automatically figures out how to map operations onto the database. |
I l @ ve RuBoard |