Hibernate recursive initialization -
I write a function in hibernate so that the whole object graph loads to recurs all properties of the recursively object.
I have two complex scenarios where I need to use it
1) Category and sub-class like the entire object itself ...
@Entity Public Category Category {@ Column (fable = false, length = 50) @noteNote @ size (max = 50, message = "{50}") string name was preserved; @ManyToOne (targetEntity = Category, Fetch = FetchType.LAZY, Optional = True) Private Category parentCategory; } 2) Complex object graph that has many objects to initialize before use
The problem is that I can not use curious induction because I want this whole object graph only in select cases, and I want to normalize the code, so there is no need to write the HQL query for the object.
I have written a partial code for this,
throws the public empty recurring Initialisy (object obj) exception (if (Hibernate.isInitialized (obj)) Hibernate. Property entry (obj); property descriptor [property] property = assets utilities for property descriptor (obj); (property descriptor property descriptor: property) {object origProp = PropertyUtils.getProperty (obj, propertyDescriptor.getName ()); if (origProp! = Null) {this.recursiveInitliaze (origProp);} If (the collection of original themes and & amp; origProp ! = Null) {Object items: (archive) origProp) {this.recursiveInitliaze (item); }}}} But there is a problem in it, it ends in stack overflow due to bi-directional relationships due to method orientation. How to find out if there is a bidirectional relationship or is there any better way of implementing it?
I think that FAF profile can also help, but still want to try to implement it because it is possible to configure the FAACH profile at the current level. Project is difficult < / Div>
You can use Hibernate.in initialize () on the object to start it . I'm not sure whether this cascade otherwise you can check out the example hibernate process which gives you an initial asset. Update: Before you begin, you do not have to cross the tree as you already do, use a hashet to keep track of the items that you have already processed.
Comments
Post a Comment