0

We have a parent type, lets say name of business sectors(eg Aviation,Defense) , based on sector we have dynamic forms that ask for sector specific data and on submit we need to store that data in table of Aviation(since user selected Aviation), also table of aviation has different fields than that of Defense or Biotechnology.

We are looking to leverage design principles and reflection in java to avoid boiler-plate code and make it as dynamic as possible

Also we use hibernate, thus we need to dynamically end-up with a valueObject VO such that we can just call

session.save(dynamicSectorVO);

Also just to give an idea about the scale of possible boiler-plate we have 26 such parent types(sectors here).

Any ideas that could help are appreciated.

Hiresh
  • 89
  • 2
  • 11
  • *leverage design principles and reflection*: usually, design principles avoid reflection. *a valueObject VO*: Hibernate doesn't save value objects. It saves entities. Entities can use inheritance though, and can also have associations to other entities, so that shouldn't be a problem. – JB Nizet Jun 03 '17 at 06:52
  • _that shouldn't be a problem_ still doesnt save us from setting all 26 entities and then writing DAO for each of them (the fields for each sectors are different) , was seeking for a bit more light on the solution, thanks for stopping by. – Hiresh Jun 03 '17 at 07:08
  • No, you don't necessarily need a DAO for each of them. As I said, inheritance is supported. session.save(foo) will save foo, whether foo is an instance of the base Foo entity, or any of its child entities. – JB Nizet Jun 03 '17 at 07:12
  • Ok, will try that out . thanks JB Nizet – Hiresh Jun 03 '17 at 07:30

0 Answers0