-->
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: Can not load many-to-one proxy - NHibernateUtil.Initialize
PostPosted: Wed Feb 01, 2006 1:43 am 
Newbie

Joined: Thu Dec 22, 2005 4:50 am
Posts: 10
Hi, I am trying to load the many-to-one relation below (AssociatedTitle). This property belongs to the class Individual, which is a subclass for Entity. Since the entity could be individual or another type of entity, i cannot load it directly through HQL.



Basically the AssociatedTitle comes back as a proxy, and I am calling
'NHibernateUtil.Initialize' to initialize it, but it does nothing,and the proxy still remains. Any Ideas?

Version of NHibernate is - NHibernate 1.0.2.0

Code Example is below.

Code:

   IQuery query;
   string HQL = string.Empty;
   HQL += "select entity from Entity entity ";
   HQL += "left join fetch entity.AssociatedJournals ";
   HQL += "left join fetch entity.AssociatedEntityType ";
   HQL += "where entity.Id = :EntityId ";
   query = theSession.CreateQuery(HQL);
   query.SetParameter("EntityId",objectToProcess.Id);
   Entity loadedEntity = (Entity)query.UniqueResult();


if (loadedEntity is Individual)
{
     if (!NHibernateUtil.IsInitialized((loadedEntity as Individual).AssociatedTitle))

{
NHibernateUtil.Initialize((loadedEntity as Individual).AssociatedTitle);
}

}
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 9:37 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Looks like a bug to me. If you can reproduce it using a small example, please report it.


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.