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]