views:

342

answers:

1

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?

+2  A: 

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".

KLE
+1. Setting **all** associations to be eagerly fetched is **never** a good idea.
ChssPly76
I was trying to set global fetching strategy to lazy
nimcap