Let say, we have a event management product for an user. One feature is, user could self-define new field to accommodate his own need, for example, he could add "do I take morning exercise today? Yes Or No " checkbox to the system, afer this, the new field will show up on the screen and its column is added to database without restart
How to design this system ? what technology is good ?
Usually we will define POJO class and mapped to database and show them on the screen. Here problem, if user dynamically add a new filed, we can't modify POJO in the runtime.
This is a challenge.
Thanks.
Hong Anderson
Ranch Hand
Joined: Jul 05, 2005
Posts: 1936
posted
0
You can use JDBC, and keep schema in XML.
For dynamic schema, you cannot use "hard-coded" classes, you need to have generic ones, like EntityData, EntityType.
Try to think about what methods EntityData and EntityType should have.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I can define object properties in xml, user could add / delete property from xml file. Then I write a JDBC generator converting xml to JDBC. This should be work.
Then another problem arises. how to define it in JSP page ? what is sequence ? do I need to define a sequence number in XML file ? or we have another options ?