-->
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.  [ 2 posts ] 
Author Message
 Post subject: Exception trying to delete an object
PostPosted: Thu Jun 02, 2005 7:57 am 
Newbie

Joined: Fri May 13, 2005 3:04 pm
Posts: 6
Location: Cleveland, OH
Hi,

I have a class called Term that has a many-to-one mapping to a class called Location. This relationship is optional. I have the mapping set as:
Code:
<many-to-one column="locationOID" name="Location" not-null="false" class="NetPark.Core.Location"/>


When trying to delete the object (whereas the Location property is null) I get the exception below.

It appears that NHibernate wants to resolve the relationship even though cascade="none". In addition it doesn't seem to understand the relationship is optional. In general, are optional relationships in NHibernate unsupported? Is there a way around this? If not, this is a major show-stopper for us!!

Please let me know. thanks.

Code:
2005-06-02 07:23:16,161 [2336] DEBUG NHibernate.Impl.SessionImpl [] <> - resolving associations for: [NetPark.Core.Term#TEST.Red]
2005-06-02 07:23:20,647 [2336] ERROR NHibernate.ADOException [] <> - could not load object
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: NHibernate
   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.Loader.Loader.LoadEntity(ISessionImplementor session, Object[] values, IType[] types, Object optionalObject, Object optionalID)
   at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Object optionalIdentifier)
   at NHibernate.Loader.EntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId)
   at NHibernate.Loader.EntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject)
   at NHibernate.Persister.EntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session)
   at NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted)

2005-06-02 07:23:20,707 [2336] ERROR NHibernate.Proxy.LazyInitializer [] <> - Exception initializing proxy.
Exception: NHibernate.ADOException
Message: could not load object
Source: NHibernate
   at NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted)
   at NHibernate.Impl.SessionImpl.ImmediateLoad(Type clazz, Object id)
   at NHibernate.Proxy.LazyInitializer.Initialize()
   at NHibernate.Proxy.LazyInitializer.InitializeWrapExceptions()

Nested Exception

Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: NHibernate
   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.Loader.Loader.LoadEntity(ISessionImplementor session, Object[] values, IType[] types, Object optionalObject, Object optionalID)
   at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Object optionalIdentifier)
   at NHibernate.Loader.EntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId)
   at NHibernate.Loader.EntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject)
   at NHibernate.Persister.EntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session)
   at NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 3:28 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Optional relationships are supported, there must be some other bug buried in here, can you please provide more information (code, class declarations, mappings)?


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