Hibernate recursive initialization

后端 未结 2 1639
孤街浪徒
孤街浪徒 2021-01-01 16:54

i am writing one function in hibernate to recursively initialize all properties of object recursively so whole object graph is loaded.

i have two complex scenarios w

2条回答
  •  抹茶落季
    2021-01-01 17:37

    you can use Hibernate.initialize() on the object to initialise it. I'm not sure if this cascades. Otherwise you could check instanceof HibernateProxy which gives you an isInitialised property.

    Update: since initialize does not cascade you need to traverse the tree like you do already. Use a Hashset to keep track of objects you already processed.

提交回复
热议问题