2 Replies Latest reply on Dec 12, 2003 7:49 PM by olevy

    Automatic update of database when CMP entity bean changes

    olevy

      When I add or remove a property to one of my CMP Entity beans, I am aware of only two ways to update the corresponding database.

      (1) Delete the table in question, and re-deploy the relevant .jar to have the table recreated. This is only OK if don't care about the existing data.

      (2) Manually add or remove columns to the database to match the new properties. This is sometimes tricky to get exactly right.

      Both of these choices are incovenient. Am I missing any options? Is there any way for this to be handled automatically?

      Thanks.

        • 1. Re: Automatic update of database when CMP entity bean change

          No other options.

          • 2. Re: Automatic update of database when CMP entity bean change
            olevy

            Actually, I can think of another option:

            Write a program for a given bean that:
            (1) pulls out all of the existing beans. If they won't all fit in memory, then it can serialize them
            (2) removes all of the beans in question
            (3) re-enters them with the new information (possibly pulling them out of serialized form)

            Then you could go one step further, and write a general purpose tool that will work on any entity bean that you point it at. Going even further you could put a nice GUI UI on top of it.

            Surely this kind of tool has already been done?