Question

I am using objectdb with jpa2. I want to let my users specify the fields of my entity. How do I do that?

For example say I have an entity named Animal and I want the user to be the one specifying the name of the fields, all Strings. How would I do that? The user can be passing me a csv file with the name of the fields such as name, owner.

Was it helpful?

Solution

You may use a Map as a persistent field in the Animal class, putting values dynamically in that map.

This, however, could be less efficient than using ordinary persistent fields.

Alternatively you can also generate entity classes dynamically using a special library (such as cglib, ASM, javassist, arch4j).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top