I have a general question involving 3 tables.
An athlete table
A coack table
A person table
Both athlete and coach should have foreign key references to the person table, that will contain data such as firstName, lastName etc.
My thought was that I would have an AbstractPerson base class that would contain the firstName lastName information, and both person and coach would extend from this base class. But, from what Im reading, it is not good to map an abstract class like AbstractPerson to the abstract table.
My second thought was that I would just create a Person object, that no classes extend from, and the coach and athlete object would delegate its name getters and setters to this Person class. But I cant seem to get the mapping straight.
Here is what I have so far:
<hibernate-mapping>
<class name="btg.athletics.domain.Person" table="person" lazy="false">
<id name="id">
<generator class="increment"/>
</id>
<property name="sport" />
<property name="firstName" />
<property name="lastName" />
</class>
<class name="btg.athletics.domain.Athlete" table="athlete" lazy="false">
<id name="id">
<generator class="increment"/>
</id>
<one-to-one name="person" class="btg.athletics.domain.Person" foreign-key="personId" cascade="all" constrained="true"></one-to-one>
<property name="classStatus" />
<property name="hometown" />
<property name="number" />
<property name="position" />
<property name="height" />
<property name="weight" />
<property name="active" />
</class>
<class name="btg.athletics.domain.Coach" table="coach" lazy="false">
<id name="id" type="integer">
<generator class="increment"/>
</id>
<one-to-one name="person" class="btg.athletics.domain.Person" foreign-key="personId" cascade="all" ></one-to-one>
<property name="description" />
<property name="notes" />
</class>
<class name="btg.athletics.domain.Sport" table="sport">
<id name="id" type="integer">
<generator class="increment"/>
</id>
<property name="name" />
</class>
</hibernate-mapping>
I know this is, in theory, relatively simple, but when I run Im getting the following error.
org.springframework.orm.hibernate3.HibernateSystemException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
Inside my AbstractPerson constructor, I instantiate a member variable person(Person) so I dont get null pointer exceptions, and the form populates my Pogo with the first and last name.
Thank you so much
Brian
|