I have a requirement to create a component that can be used stand-alone or in a larger application. When using offline mode, it should not require a database, as well as dependencies associated with the database / ORM. When used as part of a larger application, some of the classes will actually be stored in the database through JPA / Hibernate.
I thought that the domain objects in the component would not contain annotations (due to the requirement not to have dependencies associated with ORM). In a larger application, I would then subclass these domain objects ... as for how much I did it.
As a rule, I use field level annotations. Is this possible due to the scenario described above? I dont think about it.
Another thought that I had to switch to annotating properties. In this case, I would expand the non-annotated domain object by overriding all the properties and annotating them. The child will be just a delegate with the required annotations. It just looks like work / code.
Ironically, I think it would be easier to do if I used hbm.xml, which we recently left. Am I missing something with annotations?
source
share