In our design, we have a GUI that allows our customers to create tables and rows in those tables on the fly. We want to map these tables to entity beans, but the dilemma is, you don't know ahead of time what the tables/rows will look like, so how do you precreate entity beans that map that data? We also have a very distributed system, so creating entity beans on the fly and mapping them to all the appservers would be challenging. I was looking for some feedback on possible solutions for this problem. In the old world, we simply used SQL and pulled table names/rows out of the dynamic data provided by the customer. We want to use entity beans for the added benefits you get from them, but how do you make them dynamic to support a dynamic data model?
posted 13 years ago
The answer is you don't. Don't use Entity beans for this. Use standard Java objects and JDBC just like "in the old days". A generic Java design that represents the SQL metadata as "tables" containing "rows" made up of "columns" might be your best bet. You can still get the rest of the J2EE advantages (transactions, security, etc.) by using Session beans to wrap these things. Kyle