title: Allowing users to add their own custom fields in a Spring MVC Hibernate application - What's an ideal approach?
body: <p>We all may have seen applications like JIRA, or many CRM or other applications that allow its users to define their own custom fields to an entity, and do a variety of stuff with it, like making them mandatory, validate their values and so on.</p>
  
  <p>I want to do just that in the Product we are creating. </p>
  
  <p>Let's assume our product allows a user to create his/her own Project. A project has pre-defined attributes such as</p>
  
  <ul>
  <li>Name (String)</li>
  <li>Description (CLOB)</li>
  <li>Type (String)</li>
  <li>Owner (String)</li>
  <li>Status (String)</li>
  </ul>
  
  <p>Now, as a user, I would like to add the following custom field to my project</p>
  
  <ul>
  <li>Due Date (Date)</li>
  </ul>
  
  <p>Ideally he should be able to create a custom field in my product which would capture the following details:</p>
  
  <ul>
  <li>Name of the field</li>
  <li>Type of the field</li>
  <li>Default Value</li>
  <li>List of values (if the field is to be a drop down list)</li>
  <li>Mandatory or not</li>
  </ul>
  
  <p>Similarly, I would like to allow this feature of adding custom attributes not only to a project, but to a few other entities as well. </p>
  
  <p>This is the technology stack we're using and so far we're pretty ok with it.</p>
  
  <ul>
  <li>Spring MVC, JSP and jQuery as the Web Framework and for the Views</li>
  <li>JPA with Hibernate for persistence</li>
  <li>Oracle, MS SQL, MySQL - Currently our product works on these databases.</li>
  </ul>
  
  <p>How do I approach this requirement? I would like to be educated on the following:</p>
  
  <ul>
  <li>How to I decide the best data model for this? Do I add a separate table for custom field definitions, and another one for their values, and associate them to my entity by means of a foreign key?</li>
  <li>What should I do in my JSP/JS Layer to dynamically paint a screen with whatever custom fields that are defined?</li>
  <li>How do I let Spring MVC and Hibernate handle all this data model and the views?</li>
  </ul>
  
  <p>I have read a couple of questions here, specifically this</p>
  
  <p><a href="https://stackoverflow.com/questions/40383924/adding-custom-fields-in-my-application" title="this">Adding custom fields in my application</a></p>
  
  <p>Reading this, I could figure out I could use NoSQL databases to achieve this functionality. While I could do that, I want to know if there's any way I can achieve this in my current technology stack so as not introduce something new at this stage of my product evolution.</p>
  
  <p>I'm extremely sorry if my question is not framed or worded properly. I'm relatively new to these technologies, and would like to learn with each challenge.</p>
  
  <p>Thanks,
  Sriram</p>