Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Modifying CMP entity bean definitions  RSS feed

 
Frank Silbermann
Ranch Hand
Posts: 1408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose we have an EJB application in production that uses CMP entity beans. A new requirement / enhancement / correction requires that we modify the entity bean definitions. This might involve adding new managed fields, removing a managed field, or whatever. The database schema must change. How is the database conversion performed?

With simple JDBC, one decides on a new schema and performs a database conversion (perhaps with the help of a DBA), and modifies the JDBC to refer to the new schema. But with CMP entity beans, the database and its schema are generated by the J2EE container!

I cannot imagine that the container could compare two versions of an application to deduce the SQL needed to convert the database, so I presume the conversion must be done manually. This means that we must know exactly the schema that would have been generated by the J2EE container, and change it ourselves. Or, perhaps, we would rename the tables generated by the first version, compare them to the tables generated by the new application, and figure out how to move the data from the old tables to the new tables.

In any case, it seems like a complicated ordeal, and I am surprised to have seen so little written about it.

What are your experiences in dealing with changes to CMP entity beans in a production application?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose this all has to do with the ejb container you're using. If you had the server generate the database tables in the first place I suppose this could be a problem. I don't recall the "upgrade" of databases being a big feature, so I figure most won't do it. I'd go for trying to do it myself (ALTER TABLE, etc). Just make sure that you don't let your server delete the database/tables when it un-deploys the application before you do your upgrade!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!