In hibernate mapping, I have set the property lazy="false"
, and this fetches all the child records of the parent.
This is being used throughout the application.
This creates a performance issue at a particular module of my application, wherein I would like to fetch only the parent record.
I cant change the lazy
property to true
since it's being used at many other places. Is there a way to fix this?
Do let me know if any more info is required.
These is no such feature in hibernate as it respects your
lazy="false"
. So, what can I suggest to address your requirement is extends your querying class with another dummy concrete class and define mapping for that class without that child association in it.let say you have class Parent with Child mapping in it
and mapping for Parent you have is
Then you can create another class which extends Parent class
Then map it as bellow
And use this
MinimalParent
class wherever you require just parent object. hope you got it!You should probably set lazy="true" to fetch only parent as a default, and use JPQL queries with "fetch join" to fetch parent together with children wherever it is required, e.g.: