views:

321

answers:

1

I have the following structure:

[Class]
public class SuperClass
{
}

[JoinedSubclass]    
public class SubClass : SuperClass
{
}

[Class]
public class ContainerClass
{
  [ManyToOne]
  public SuperClass SomeProperty {get; set;}
}

However, when retrieving an instance of ContainerClass via Hibernate.ISession.Get, it always returns me an instance of superclass, even when the item in question should be an instance of subclass. The hibernate documentation suggsets this should just work, so maybe I'm missing an annotation?

A: 

Turns out if you make the association eagerly loaded then it fixes the problem. Otherwise the lazyinitialiser proxy always defaults to the superclass type. Seems like this is a bug in hibernate, although perhaps there's a good technical reason why you can't make it work