java - Using List collection makes Hibernate throw stackoverflow error -


I have three domain objects, one parent object with the two children, the parent object with the two children There is a lot of relationship, and therefore there is a collection of guardian items in both children, whereas parents are references to the objects of both children.

Parents

Pre> parents of the public class {other children other children; Some children some children; / * Other methods and attributes * / @ManyToOne (fetch = FetchType.EAGER) Public SomeChild getSomeChild () {this.someChild; } Public Zero Set Some Children (Some Children Some Children) {this.someChild = someChild; } @ManyToOne (fetch = FetchType.EAGER) Public other children meet other infants () {this return.otherChild; } Public Zero set other infant (other children other children) {this.otherChild = otherChild; }}

Kids

  Public category SomeChild {Private list & lt; Parents & gt; mother-father; / * Other methods and attributes * / @OneToMany (fetch = FetchType.LAZY, mapped = "some child") Public list & lt; Parent & gt; Recipient () {Back Parents; } Public zero set parents (list & lt; parent & gt; parent) {this.parents = parent; }}  

I am using Hibernate with JPA annotations to continue this setup in the database, but when any child has a list of parents in my list, then I Stack overflow error is trying to bring parents (children are identified in both parents as FetchType.EAGER ). When I change the fetching to FetchType.LAZY , the parent fixes the work, but bringing the children alone causes a stack overflow error (seeing from SQL), Hibernate still tries parents to mark parents' collection in children as lazy .

The normal use of this parent is always required to have their children received so that their mapping to fetchType.EAGER is the original object of each of the children Efforts have been made to disable eager emission, but only the error is removed while bringing the parents, but such an error arises when any child is brought. The only solution I have yet to change is the type of parent collection: list & lt; Parent & gt; Parents to set both children from the list, though I should have a list for reasons due to the collection.

  • Why does the stack overflow error occur when there is a list in the child objects
  • How can I get a list of objects in children and still curious parents Bring children to


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -