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.

有帮助吗?

解决方案

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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top