开发者

Does JPA support a kind of "Any" mapping for embeddable objects?

I'm extending the data model of an Java application to include some kind of a setting facility. Settings in this application would basically be Strings or Numbers, no entities or other model objects.

My Question is what's the best way to map this requirement to JPA (Hibernate)?

I first thought about implementing a Setting class with properties for each desired type but maybe there is a way to use something like Hibernate's Any mapp开发者_Go百科ing? The Problem with the any mapping seems to be that it is meant to express relations to entities not embeddables.

Any ideas?

edit:

To clarify the requirement. I want to persist variable data in a simple way, think about C style union or a bean property of the Object type.


Does JPA support a kind of “Any” mapping for embeddable objects?

To my knowledge, neither JPA nor Hibernate do support defining relation to embeddable which are not entities. Just in case, the JPA wikibook has a very interesting section on embeddables.

If I misunderstood your question, please clarify (again), your goal is still not clear (at least for me). Maybe a "pseudo" example could help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜