Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

## net.java.ao
Annotation Type Polymorphic

    @Retention(value=RUNTIME)
    @Target(value=TYPE)
    public @interface Polymorphic

Tags a given entity type as polymorphically abstract. This means that the given type will not peer to any table, but rather represent a polymorphic supertype to other entities (entities which extend the given interface). Unlike conventional inheritence, which also causes the supertype to not peer to a table, polymorphic type inheritence allows instances of the subtype to be stored in the database into fields which are "typed" in ActiveObjects as the supertype. All of this is really much simpler than it sounds:

    public interface Person extends Entity {
         public Computer getComputer();
         public void setComputer(Computer computer);
     }

     @Polymorphic
     public interface Computer extends Entity {
         public float getSpeed();
         public void setSpeed(float speed);
     }

     public interface Mac extends Computer {}
     public interface PC extends Computer {}

In this case, `Computer` does not correspond with any table in the database. Likewise, `Person` has no foreign keys for the corresponding field to `getComputer()`. When an entity type is polymorphic, its subtypes can be used polymorphically as they are in `Person`. This is essentially the conceptual analog of an abstract class when mapped into the database.

Author:
  Daniel Spiewak

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

Copyright © 2007-2011. All Rights Reserved.