spring - Implementing regional specific fields in Entities in Java project -


in project, there need add regional specific fields in whichever entity required. these fields visible when project run in particular region. guess done either using profiles in pom.xml or using web.xml.

for example :

employee has name, salary, age. there additional field 'regionalage' hold age in terms of hijri calendar.

considering enter these details manually on jsp, want show regional specific fields when required.

i want implement using aspect oriented programming. current implementation not developer-friendly. suggestions?

p.s. new aop , hope learn same via example.

q) how has been presently implemented?

a) new entity has been created : regionaldata. entity has limited number of fields numbered regionalfield1, 2 , on. entity needs embedded whichever entity requires regional specific fields inside of it. persisting same has been handled.

there xml file : regionalspecificmapping.xml in 'jspname' in wish use in , 'source entity name' mapped. there regional mapping table same , maps name of field source entity name , regional field number #1/2/3.

this results in creation limited number of columns created in table of entity in embedded regionaldata. in these columns, regional specific values stored.

i looking approach current 1 @ point fail include more fields , have include more fields again.

the first , simplest approach having regional fields in class making them nullable. example employee class have "regionalage" initialized if relevant current region. in presentation layer (jsp) should show fields not null.

as variant of solution can use optional either java 8 (if using java 8) or guava (if still in previous version).

second solution use base employee class , extend specific regions. employee implemented , packaged core project. can implement several extensions provide own classes extend employee , add fields. can define factory creates entities , re-define factory in each sub-project, instantiation of entities done using generic way.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -