2 Replies Latest reply on Mar 31, 2008 3:28 AM by tschlechter

    Proxy classes on @Inheritance types not honoring derived typ

    hindog

      JBoss 4.0.4 GA Patch 1, ejb3-clustered from .jar installer

      I have a hierarchy of entities using JOINED inheritance, the hierarchy is:

      Structure
      -> House
      -> Apartment

      (Structure is the root of the hierarchy flagged with @Inheritance attribute, the others extend Structure and provide @DiscriminatorValue's )

      I have @OneToMany lazy loading from another bean to get all of the "Structure"s that are associated with it, and the method returns all of the Structure's (House and/or Apartments), but the returned objects cannot be cast to their appropriate type. IE:

      List< Structure > structures = myBlock.getStructures();
      for( Structure structure : structures )
      {
      if ( structure instanceof House ) { ... } // this is always false
      if ( structure instanceof Apartment ) { ... } // this is always false
      }

      and deliberately casting to a sub-type via:

      ((House)structure).doSomething() throws a class cast exception, even though the entity in question is discriminated as a House.

      I've tried both javassist and cglib byte enhancers, both produce the ClassCastException

      So is this a bug?