CMP Entity Beans and data cleanup
Hullo,
I'm fairly new to entity beans, and I have a general design question regarding CMP entity beans. I've been trying to google for an answer but I still can't quite answer it yet.... Anyways, here's my question: as I understand it, the J2EE server is responsible for creating and removing the database tables whenever you deploy/undeploy CMP entity beans, but what I'm wondering about is how do I do table entry cleanup while the bean is deployed?For the most part, I only need data to persist for a relatively short amount of time (i.e. about a day). So naturally, I would like to remove the older entries in the table, but I can't figure out how I'm supposed to do it...
Thanks for any help!
[723 byte] By [
ak102a] at [2007-11-27 9:20:25]

# 1
Hi ak,
First, just to clarify, the issue of when the underlying database tables are created is not governed by
the EJB specification.In many cases the tables already exist before the application is deployed.
Many J2EE implementations have an ease-of-use feature that automatically creates/deletes database
tables upon deployment/undeployment, but that behavior is independent of the runtime requirements
imposed by the specification.
Likewise, database cleanup is left up to the application as well. There is nothing inherent within
CMP that automatically deletes tables. You can either add code to your application to handle this,
e.g. by creating a periodic EJB Timer that deletes data from your tables. Or, you could have a
process that is completely outside the scope of a J2EE application, such as a UNIX cron job, that
performs that task.
--ken
ksaksa at 2007-7-12 22:13:33 >
