132 Chapter 6 EJB (Free php web host) offers an alternative to

132 Chapter 6 EJB offers an alternative to bean-managed persistence: You can have your EJB container perform your persistence for you. This is called container-managed persistence. In this case, you would usually strip your bean of any persistence logic. Then, you inform the container about how you d like to be persisted by using the container s tools. The container then generates the data access code for you. For example, if you re using a relational database, the container may automatically perform SQL INSERT statements to create database data. Similarly, it will automatically perform SQL DELETE statements to remove database data, and it will handle any other necessary persistent operations. Even if you are not working with a relational database, you can have your container persist for you. If your container supports a nonrelational persistent store, such as an object database or a VSAM file, the container will generate the appropriate logic as necessary. In fact, you can wait until deployment time before you set up the O/R mapping, which is great because you can write storage-independent data objects and reuse them in a variety of enterprise environments. Container-managed persistence reduces the size of your beans tremendously because you don t need to write JDBC code the container handles all the persistence for you. This is a huge value-add feature of EJB. Of course, it is still evolving technology. Once we ve written a few entity beans, we ll review the trade-offs of bean-managed versus container-managed persistence (see Chapter 16). Creation and Removal of Entity Beans As we mentioned earlier, entity beans are a view into a database, and you should think of an entity bean instance and the underlying database as one and the same (they are routinely synchronized). Because they are one and the same, the initialization of an entity bean instance should entail initialization of database data. Thus, when an entity bean is initialized in memory during ejbCreate(), it makes sense to create some data in an underlying database that correlates with the in-memory instance. That is exactly what happens with entity beans. When a bean-managed persistent entity bean s ejbCreate()
For the first time, E-commerce websites allow small and large companies to actually compete on a level playing field.We highly recommend you to visit ecommerce website hosting.

Leave a Reply