I am faced with an unusual problem in a project that I am developing. The requirements are not clear regarding the size of a dozen or so text area input fields on the web page and as a result of which, I find myself having to change not only the database column to increase length but also to change the size parameter specified in my JSF validator for that text area component. Since the code has changed, an emergency deployment is necessary which makes a lot of people mad. Unfortunately, no one is quite sure what length these data elements should be and we expect it to change often. I changed my varchars to clobs but unfortunately the clob sizes were also too small and had to be increased as well.
Are there any tools or APIs that will help me address this problem? Or any best practices? I am considering building a small, on demand feature that will generate all db column lengths and make it available to the application via a singleton class. The UI view would then reference that particular element thus eliminating the need for code deployment.
Does anyone have any better solutions?
I am using JSF1.2+EJB3+Weblogic+Oracle DB stack.
Thanks a lot for looking.
Your problem seems to be extreme case of a pretty normal use case.. (varchar to clob…:) )
You have not mentioned any ORM framework and I assume that you are not using Hibernate.
The first solution that comes to my mind is Using JSR 303 . Its a very scalable, non intrusive validation framework. You can implement this framework in whichever tier you want to. To hold the whole thing together, you could provide a single custom constraint validator , that will internally have a way of loading max and min values based on the field. The idea is to pass an parameter via annotation, indicating the field name, storing the min-max value of each field name in some external property file. So the validator, will dynamically load min max value based on the field name.
So you have a customized framework for validating each fields based on constraints stored in a property file. You could reuse the same constraint both in your presentation and also your DAO layer.
Of course, one things is unanswered.
1.How to propogate this change to the underlying database. You could provide maximum possible length in database and handle contraints in your application tier, but there might be performance consideration. (although, I doubt there will be. Oracle is very very intelligent in its CBO).
Look here for a general example.
P.S: I have never tried this customization myself, but it is definitely possible.