开发者

Hibernate: Entities vocabulary(in-memory storage)

开发者 https://www.devze.com 2023-02-06 09:56 出处:网络
Vocabularies is common thing when using pure SQL. Just store some static tables(rarely updated entries - such as types, cities list, etc.) in memory andupdate when needed - very nice approach because

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

精彩评论

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