Discussions

General J2EE: CMP, how to insert data in a database (via create)- overhead ???

  1. Is it rigth that the only way to insert data in a database is to use the method create(). But when you use create() don't you create an instans of the Bean each time ? Is't that overhead in your system ? I would prefer to create one instance of my Bean one time instead of creating an instance each time I am inserting data in the database.




  2. In fact according to the EJB spec, the container usually picks up an unpopulated instance of a bean from a bean pool and populates with the data. When the instance was idle for too long it gets passivated, 'depopulated' and returns back to the pool, and later will be repopulated as some other instance. So in fact, actual object instantiation may happen only on startup or if the container needs more instances simultaneously than it has in the pool. This implementation is not a requirement, just an opportunity, but all known EJB containers use it.