nimcap
nimcap

Reputation: 10523

How to change hibernate's default fetching strategy?

I know hibernate's default fetching strategy is LAZY for collections, is there a way to change the default fetching strategy system wide through configuration file?

Upvotes: 2

Views: 3250

Answers (1)

KLE
KLE

Reputation: 24169

I don't know any good answer for your need, sorry. :-(


But may I dare challenging your requirement? ;-)

  1. If you enable early fetching for collections (ie. XToMany, or parent to child relationship), it is probable that it is also adequate to enable the other side (XToOne), that is much more likely needed.

  2. Considering that often, your entities are not fully partitionned, that is "there is a chain of entities allowing to go from any entity to any other entity"...

  3. We deduce that even your simplest request will load the entire database !

This is the reason why I think it is "unlikely a good idea".

Upvotes: 2

Related Questions