The tutorial example uses the table per class strategy to map an inheritance relationship of Pet, which is the base class for Cat and Dog.
With the table per class strategy there is a table per class in the hierarchy, and each table has every single property that particular class will persist.
This is what the annotations look like for Pet.
@Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class Pet implements java.io.Serializable {
The subclass annotations look like this.
@Entity public class Dog extends Pet {
public List findByWeight(double weight) { return manager.createQuery("from Pet p where p.weight < :weight").setParameter("weight", weight).getResultList(); }
Even though the findByWeight method queries on Pet, either Dog or Cat instances can be returned.
create table CAT ( ID integer primary key, LIVES int NAME varchar, WEIGHT double ); create table DOG ( ID integer primary key, NUMBONES int NAME varchar, WEIGHT double );
To load subclasses the persistence manager must before a SQL join. This is less efficient than the single table strategy as the SQL query is more complicated.
Unix: $ export JBOSS_HOME=<where your jboss 4.0 distribution is> Windows: $ set JBOSS_HOME=<where your jboss 4.0 distribution is> $ ant $ ant run run: [java] 2004-10-07 00:16:20,395 INFO org.jboss.remoting.InvokerRegistry[main] - Failed to load soap remoting transpo rt: org/apache/axis/AxisFault [java] Sox [java] Junior
The INFO message you can ignore. It will be fixed in later releases of JBoss 4.0.