1 Reply Latest reply on Apr 10, 2011 8:44 PM by Viacheslav Garmash

    Lazy polymorphic relations possible?

    Stefan Craatz Newbie


      we have an entity which has a many-to-one property that references a polymorphic entity.

       @ManyToOne(cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER) // EAGER
       @JoinColumn(name = "wle_mbtid", unique = false, nullable = true, insertable = true, updatable = true)
       public Musterbestandteil getMusterbestandteil() {
       return this.musterbestandteil;

      The Musterbestandteil class is the base class for several sub-classes. When I load the property eagerly everything works as expected, but when it is lazily loaded "instanceof" does not work because the property is some CGLIBxxx class.

      Is there a way around this or do I have to load polymorphic relations eagerly. That would lead into trouble with entities that have more than one polymorphic x-to-many relations.