-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Selfreference using ManyToOne produces StackOverflowError
PostPosted: Tue May 22, 2007 2:02 pm 
Beginner
Beginner

Joined: Fri Jan 14, 2005 7:47 am
Posts: 37
Location: Spain
Hi,

when I use a selfreference Hibernate fails with a StackOverflowError.

My code is:

Code:
@Entity
public class Ingredient {
   
   @Id @Hidden
   @GeneratedValue(generator="system-uuid")
   @GenericGenerator(name="system-uuid", strategy = "uuid")
   @Column(name="ID")
   private String oid;
   
   @Length(max=40) @Required
   private String name;
   
   
   @ManyToOne(fetch=FetchType.LAZY)
   @JoinColumn(name="PARTOF")
   private Ingredient partOf; // The failed reference

// Setters and getters


Any time that I want ot access to a object of type Ingredient using the EntityManager a StackOverflowError is produces without stacktrace (and I have put ALL log level for Hibernate).

Hibernate version: Hibernate 3.2.4.sp1, Hibernate EntityManager 3.3.1.GA and Hibernate Annotations 3.3.0.

Does Hibernate JPA implementation support selfreferences ?
Maybe ss this a Hibernate bug ?
or am I missing something ?

Thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 6:54 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes it supports self references, usually such stack overflow comes from a wrong implementation of the POJO (like a getter or toString or equals)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 1:27 pm 
Beginner
Beginner

Joined: Fri Jan 14, 2005 7:47 am
Posts: 37
Location: Spain
emmanuel wrote:
yes it supports self references


You are right. The problem was in my code.

Thank you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.