hibernate的column級(jí)lazy
1. Using lazy property fetchingTo enable lazy property loading, set the lazy attribute on your particular property mappings:
<class?name="Document">
???????<id?name="id">
????????<generator?class="native"/>
????</id>
????<property?name="name"?not-null="true"?length="50"/>
????<property?name="summary"?not-null="true"?length="200"?lazy="true"/>
????<property?name="text"?not-null="true"?length="2000"?lazy="true"/>
</class>
???????<id?name="id">
????????<generator?class="native"/>
????</id>
????<property?name="name"?not-null="true"?length="50"/>
????<property?name="summary"?not-null="true"?length="200"?lazy="true"/>
????<property?name="text"?not-null="true"?length="2000"?lazy="true"/>
</class>
Lazy property loading requires buildtime bytecode instrumentation! If your persistent classes are not enhanced, Hibernate will silently ignore lazy property settings and fall back to immediate fetching.
For bytecode instrumentation, use the following Ant task:













Please note that this is mostly a marketing feature, as in practice, optimizing row reads is much more important than optimization of column reads.
debug麻煩, 并沒(méi)有測(cè)試
2. use hql












以上兩種方法在實(shí)際應(yīng)用中都不是很理想, 但那種from Pojo的方式太浪費(fèi)內(nèi)存, 遇到blob字段更可怕, 有其他更好方法的請(qǐng)告知
posted on 2006-04-10 20:28 waterye 閱讀(2017) 評(píng)論(1) 編輯 收藏 所屬分類: hibernate