开发者

Hibernate entity with user defined attributes

Can someone please give me some tips on modeling hibernate entities that have some known attributes while the majority are defined by the user of the system (during initial setup of the开发者_如何学Go system)

I need to be able to search on these user defined attributes at a later point in time.


First of all you'll need to decide on how you're going to model this. Two most common approaches are Entity-Attribute-Value model and row modeling.

The former is (much) easier to deal with using Hibernate; however depending on the search criteria you intend to use it may perform (very) poorly. Certain criteria can not be translated to a single SQL query at all.

The latter is harder to implement as you're looking at both altering your database schema dynamically at runtime and changing Hibernate's configuration to match. Take a look at my answer to How to map dynamically created table in Hibernate for more detail if you choose to go this route.

Another possible alternative is to use Hibernate's support for XML mapping but, again, depending on your search criteria and XML functionality (if any) supported by your underlying database this may or may not be a viable option.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜