According to JBoss 2.4.x documentation, you'd need to set <remove-table>true</remove-table> for the default entity. When the bean is undeployed, i.e. removed from the deploy directory, the table should be dropped. Unfortunately, I can't seem to get this feature to work...
<remove-table>true</remove-table> in the defaults section of your jbosscmp-jdbc.xml file should do the trick. I can't remember if this works properly in the alpha. I seem to remember the undeployer being broken, but I'm not sure.
Not only do you have to set the <remove-table> tag to true in the jaws.xml or cmp-jdbc.xml file, you have to blow away the database files in jboss/db/hypersonic/. Make sure you kill Jboss first, then delete the files inside this directory. When you restart jboss, all your entities will be gone, but now you will be able to undeploy your beans and have the data disappear with them.
One big problem still is getting Hypersonic to store the db on disk rather than in memory. What happens over time is the script file grows absolutely huge with meaningless SQL commands--every execution on the database gets written to this script file.
Every time one starts up, then, the db re-runs the entire script, which means every single command since the db was first created gets re-executed.
I am trying to find a way to edit the SQL jboss uses to create the table to use hypersonic's disk-based tables to avoid this problem. Any ideas?
just an idea but... you could write some form of parser to optimise the SQL queries stored in the hypersonic SQL script. i.e. if a matching insert and delete are found tyhen remove them both.