开发者

Hibernate: Entities vocabulary(in-memory storage)

Vocabularies is common thing when using pure SQL. Just store some static tables(rarely updated entries - such as types, cities list, etc.) in memory and update when needed - very nice approach because you haven't create tonns of connections and property binding...

But what abou开发者_StackOverflowt Hibernate with it's sessions, transactions, versions, etc. ? Does it allows to create such vocabulary ?

P.S. The most interesting thing is - transient objects. Because of number of different sessions and transactions where vocabularies will be used. So each time we get object from vocabulary we have to invoke merge() but wouldn't it perform any communication with DB ?


Hibernate provieds a readonly mapping: mutable=false (or add @Immutable to your class) This should result in less memory consumtion.

And you can enable caching for this class.


As long as the vocabulary items are entities in their own right, and references to them are lazy-loaded, Hibernate's second-level cache should allow them to be supplied from memory without going to the database.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜