-->
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.  [ 6 posts ] 
Author Message
 Post subject: Tree structures
PostPosted: Fri Sep 09, 2005 2:06 am 
Newbie

Joined: Fri Sep 09, 2005 2:00 am
Posts: 9
Hi,

I'm trying to create a tree structure with many-to-one from child to parent and one-to-many from parent to child relationships. Tree is kept in database as single table with every record having "parent_id" foreign key pointing to primary key in same table. However, reading any node from the database instantly gives me OutOfStackException.

Has anybody implemented something like this with NHibernate and is willing to share how he/she did it? :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 7:45 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Try enabling lazy-loading for your node class. Use lazy="true" in <class> element, and make all its properties and methods virtual.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 9:04 am 
Newbie

Joined: Fri Sep 09, 2005 2:00 am
Posts: 9
Unfortunately, it did not help. Message I get is:

NHibernate.PropertyAccessException: could not set a property value by reflection setter of Motor.Core.Structure.Folder.Parent ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.StackOverflowException: Exception of type System.StackOverflowException was thrown.
--- End of inner exception stack trace ---
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at NHibernate.Property.BasicSetter.Set(Object target, Object value)
--- End of inner exception stack trace ---
at NHibernate.Property.BasicSetter.Set(Object target, Object value)
at NHibernate.Persister.AbstractEntityPersister.SetPropertyValues(Object obj, Object[] values)
at NHibernate.Impl.SessionImpl.InitializeEntity(Object obj)
at NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList hydratedObjects, Object resultSetId, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Hql.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 9:13 am 
Newbie

Joined: Fri Sep 09, 2005 2:00 am
Posts: 9
Got is solved. My own stupidity. My own code was actually generating stack overflow... :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 9:14 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
are you sure it's not a bad property?? it doesn't seem to have anything to do with the 1-many

--- whoops, i was too late :D


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 9:37 am 
Newbie

Joined: Sun Nov 20, 2005 9:00 am
Posts: 3
Pleeeeease look at my post here. I'm trying to do a tree too but made out of cats :) from the nhibernate example. I am missing something and I don't know what..../....



http://nhibernate.sourceforge.net/forum ... php?t=1381


Tx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.