I am trying to use the OJB XDoclet to generate a mapping for a test object
hierarchy and am now not sure if I am approaching this correctly.
I have put the code for the various classes at the end iof this - I have
chopped out all but the data members for clarity.
What I want is to be able to store PFYs or BOSSes in the EMPLOYEE Table and
to be able to get OJB to query either Boss, Pfy or BaseEmployee for me if I
ask it to, although the BaseEmployee will prob not really be needed but I'd
like to know I could do it.
When I run the OJB XDoclet on this the repository seems to be correct (I
haven't tried it but it looks like it would work) but the db schema XML has
a table for BaseEmployee, PFY and BOSS. I was hoping that I would get one
table (EMPLOYEE) which had the superset of all fields for all objects that
had to be stored in it.
It would be a great help if someone could clarify if I am on the right
track, whether OJBs XDoclet can do what I want or if I should go back to raw
JDBC :-)
Thanks in advance,
Nigel
BaseEmployee
package xdoctest;
import java.io.Serializable;
import java.util.Vector;
/**
* @ojb.class generate-table-info="false"
*/
public abstract class BaseEmployee implements Serializable{
/**
* @ojb.field primarykey="true"
* autoincrement="ojb"
* sequence-name="seq_employeeid"
* nullable="false"
*/
protected Integer employeeID;
/**
* ojb.field nullable="false"
*/
protected Integer deskNumber;
/**
* ojb.field nullable="false"
*/
protected Long daysInJob;
/**
* ojb.field nullable="false"
*/
protected Double salary;
/**
* ojb.field nullable="false"
*/
protected Integer holidaysLeft;
/**
* @ojb.collection element-class-ref="xdoctest.Holiday"
* foreignkey="employeeID"
* auto-retrieve="true"
* auto-update="true"
* auto-delete="true"
*/
protected Vector holidays = null;
}
PFY
package xdoctest;
/**
* @ojb.class table="EMPLOYEE"
* include-inherited="true"
*/
public class PFY extends BaseEmployee {
/**
* @ojb.field
*/
protected Long daysInProbationLeft;
}
Boss
package xdoctest;
import java.util.Vector;
/**
* @ojb.class table="EMPLOYEE"
* include-inherited="true"
*/
public class Boss extends BaseEmployee {
/**
* @ojb.field
*/
protected Boolean hasKeyToExecJacks;
/**
* @ojb.field
*/
protected Boolean hasCompCar;
/**
* @ojb.field
*/
protected Integer numberofPFYsOnTeam;
/**
* @ojb.collection element-class-ref="xdoctest.PFY"
* foreignkey="employeeID"
* auto-retrieve="true"
* auto-update="link"
* auto-delete="none"
*/
protected Vector pfys = null;
}
Holiday
package xdoctest;
import java.io.Serializable;
import java.sql.Date;
/**
* @ojb.class table="HOLIDAYS"
*/
public class Holiday implements Serializable {
/**
* @ojb.field primarykey="true"
* autoincrement="ojb"
* sequence-name="seq_holidayid"
* nullable="false"
*/
protected Integer holidayID;
/**
* @ojb.field nullable="false"
*/
protected Integer employeeID;
/**
* @ojb.field nullable="false"
*/
protected Date startdate;
/**
* @ojb.field nullable="false"
*/
protected Integer numDays;
/**
* @ojb.field nullable="false"
*/
protected Date returnDate;
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.721 / Virus Database: 477 - Release Date: 17/07/2004
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]