Hi Andy, Erik,

I'm testing a new mapping wrt inheritance. For this purpose, I wrote a new schema file and a new orm file based on the company model for application identity. The mapping applies inheritance strategy "new-table" in conjunction with a join condition for subclassses classes Employee, PartTimeEmployee, FullTimeEmployee, MedicalInsurance, and FullTimeInsurance.

We use the CompletenessTest for testing different mappings. The test persists some objects. Afterwards it checks if the objects in database and in memory are equal.

When I run the CompletenessTest using that mapping, then I receive a SQL Exception (see below). The exception is thrown at check time. This means, that object have been made persistent successfully. The database contains reasonable entries.

I'm not sure if the exception is thrown due to an error in the mapping or due to a bug in JPOX. Can you please check the attached files? I attached the schema file and the orm file. You find the corresponding Java files in TCK20 subproject in package "org.apache.jdo.tck.pc.company".

Regards,
Michael

test(org.apache.jdo.tck.mapping.CompletenessTest)javax.jdo.JDODataStoreException: Fetch request failed: SELECT applicationidentity1.DENTALINSURANCE.INSID,applicationidentity1.PERSONS.PERSONID FROM applicationidentity1.EMPLOYEES LEFT OUTER JOIN applicationidentity1.INSURANCEPLANS ON applicationidentity1.EMPLOYEES.PERSONID = applicationidentity1. INSURANCEPLANS.EMPLOYEE INNER JOIN applicationidentity1.PERSONS ON applicationidentity1.EMPLOYEES.PERSONID = application
identity1.PERSONS.PERSONID WHERE (applicationidentity1.PERSONS.PERSONID = ?)
[java] at org.jpox.store.rdbms.request.FetchRequest.execute(FetchRequest.java:196) [java] at org.jpox.store.rdbms.table.ClassTable.fetch(ClassTable.java:1771) [java] at org.jpox.store.rdbms.table.ClassTable.fetch(ClassTable.java:1764)
    [java]      at org.jpox.store.StoreManager.fetch(StoreManager.java:684)
[java] at org.jpox.state.StateManagerImpl.loadNonDFGFields(StateManagerImpl.java:1612) [java] at org.jpox.state.StateManagerImpl.isLoaded(StateManagerImpl.java:1733) [java] at org.apache.jdo.tck.pc.company.Employee.jdoGetdentalInsurance(Employee.java) [java] at org.apache.jdo.tck.pc.company.Employee.deepCompareFields(Employee.java:455) [java] at org.apache.jdo.tck.pc.company.FullTimeEmployee.deepCompareFields(FullTimeEmployee.java:119) [java] at org.apache.jdo.tck.mapping.CompletenessTest.test(CompletenessTest.java:99) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:197)
[java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128) [java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106)
    [java] NestedThrowablesStackTrace:
[java] ERROR 42X04: Column 'APPLICATIONIDENTITY1.DENTALINSURANCE.INSID' is not in any table in the FROM list or it a ppears within a join specification and is outside the scope of the join specification or it appears in a HAVING clause a nd is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'APPLICATIONIDENTITY1.DENTALINSURANCE
.INSID' is not a column in the target table.
[java] at org.apache.derby.iapi.error.StandardException.newException(StandardException.java) [java] at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(ColumnReference.java) [java] at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(ResultColumn.java) [java] at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(ResultColumnList.java) [java] at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(SelectNode.java) [java] at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(DMLStatementNode.java) [java] at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java) [java] at org.apache.derby.impl.sql.compile.ReadCursorNode.bind(ReadCursorNode.java) [java] at org.apache.derby.impl.sql.compile.CursorNode.bind(CursorNode.java) [java] at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java) [java] at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java) [java] at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLangu
ageConnectionContext.java)
[java] at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java) [java] at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(EmbedPreparedStatement20.java) [java] at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(EmbedPreparedStatement30.java) [java] at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Driver30.java) [java] at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java) [java] at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java) [java] at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:303) [java] at org.jpox.store.rdbms.request.FetchRequest.execute(FetchRequest.java:140) [java] at org.jpox.store.rdbms.table.ClassTable.fetch(ClassTable.java:1771) [java] at org.jpox.store.rdbms.table.ClassTable.fetch(ClassTable.java:1764)
    [java]      at org.jpox.store.StoreManager.fetch(StoreManager.java:684)
[java] at org.jpox.state.StateManagerImpl.loadNonDFGFields(StateManagerImpl.java:1612) [java] at org.jpox.state.StateManagerImpl.isLoaded(StateManagerImpl.java:1733) [java] at org.apache.jdo.tck.pc.company.Employee.jdoGetdentalInsurance(Employee.java) [java] at org.apache.jdo.tck.pc.company.Employee.deepCompareFields(Employee.java:455) [java] at org.apache.jdo.tck.pc.company.FullTimeEmployee.deepCompareFields(FullTimeEmployee.java:119) [java] at org.apache.jdo.tck.mapping.CompletenessTest.test(CompletenessTest.java:99) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:197)
[java] at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128) [java] at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106)
--
-------------------------------------------------------------------
Michael Watzek                  [EMAIL PROTECTED] Engineering GmbH
mailto:[EMAIL PROTECTED]        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------
-- SchemaType: application identity

-- Inheritance mapping: 
-- Separate table for each class in the inheritance hierarchy.
-- See tables "persons", "employees", "parttimeemployees", 
-- "fulltimeemployees", "insuranceplans", "medicalinsurance", and 
"dentalinsurance".

connect 'jdbc:derby:jdotckdb;create=true' user 'tckuser' password 'tckuser';

CREATE SCHEMA applicationidentity1;
SET SCHEMA applicationidentity1;

-------------------------
-- company
-------------------------

ALTER TABLE departments DROP CONSTRAINT EMP_MO_FK;
ALTER TABLE project_reviewer DROP CONSTRAINT PR_PROJ_FK;
ALTER TABLE project_reviewer DROP CONSTRAINT PR_REV_FK;
DROP TABLE dentalinsurance;
DROP TABLE medicalinsurance;
DROP TABLE insuranceplans;
DROP TABLE project_reviewer;
DROP TABLE project_member;
DROP TABLE employee_phoneno_type;
DROP TABLE fulltimeemployees;
DROP TABLE parttimeemployees;
DROP TABLE employees;
DROP TABLE persons;
DROP TABLE projects;
DROP TABLE departments;
DROP TABLE companies;

CREATE TABLE companies (
    ID INTEGER NOT NULL,
    NAME VARCHAR(32) NOT NULL,
    FOUNDEDDATE VARCHAR(32) NOT NULL,
    ADDRID INTEGER,
    STREET VARCHAR(64),
    CITY VARCHAR(64),
    STATE CHAR(2),
    ZIPCODE CHAR(5),
    COUNTRY VARCHAR(64),
    CONSTRAINT COMPS_PK PRIMARY KEY (ID)
);

CREATE TABLE departments (
    ID INTEGER NOT NULL,
    NAME VARCHAR(32) NOT NULL,
    EMP_OF_THE_MONTH INTEGER,
    COMPANYID INTEGER REFERENCES companies,
    CONSTRAINT DEPTS_PK PRIMARY KEY (ID)
);

CREATE TABLE persons (
    PERSONID INTEGER NOT NULL,
    FIRSTNAME VARCHAR(32) NOT NULL,
    LASTNAME VARCHAR(32) NOT NULL,
    MIDDLENAME VARCHAR(32),
    BIRTHDATE VARCHAR(32) NOT NULL,
    ADDRID INTEGER,
    STREET VARCHAR(64),
    CITY VARCHAR(64),
    STATE CHAR(2),
    ZIPCODE CHAR(5),
    COUNTRY VARCHAR(64),
    CONSTRAINT PERS_PK PRIMARY KEY (PERSONID)
);

CREATE TABLE employees (
    PERSONID INTEGER NOT NULL,
    HIREDATE VARCHAR(32),
    WEEKLYHOURS FLOAT,
    DEPARTMENT INTEGER REFERENCES departments,
    FUNDINGDEPT INTEGER REFERENCES departments,
    MANAGER INTEGER REFERENCES persons,
    MENTOR INTEGER REFERENCES persons,
    HRADVISOR INTEGER REFERENCES persons,
    CONSTRAINT EMPS_PK PRIMARY KEY (PERSONID),
    CONSTRAINT EMPS_FK FOREIGN KEY (PERSONID) REFERENCES persons (PERSONID)
);

CREATE TABLE parttimeemployees (
    PERSONID INTEGER NOT NULL,
    WAGE FLOAT,
    CONSTRAINT PTEMPS_PK PRIMARY KEY (PERSONID),
    CONSTRAINT PTEMPS_FK FOREIGN KEY (PERSONID) REFERENCES persons (PERSONID)
);

CREATE TABLE fulltimeemployees (
    PERSONID INTEGER NOT NULL,
    SALARY FLOAT,
    CONSTRAINT FTEMPS_PK PRIMARY KEY (PERSONID),
    CONSTRAINT FTEMPS_FK FOREIGN KEY (PERSONID) REFERENCES persons (PERSONID)
);

CREATE TABLE insuranceplans (
    INSID INTEGER NOT NULL,
    CARRIER VARCHAR(64) NOT NULL,
    EMPLOYEE INTEGER REFERENCES persons,
    CONSTRAINT INS_PK PRIMARY KEY (INSID)
);

CREATE TABLE medicalinsurance (
    INSID INTEGER NOT NULL,
    PLANTYPE VARCHAR(8),
    CONSTRAINT MEDINS_PK PRIMARY KEY (INSID),
    CONSTRAINT MEDINS_FK FOREIGN KEY (INSID) REFERENCES insuranceplans (INSID)
);

CREATE TABLE dentalinsurance (
    INSID INTEGER NOT NULL,
    LIFETIME_ORTHO_BENEFIT DECIMAL,
    CONSTRAINT DENTINS_PK PRIMARY KEY (INSID),
    CONSTRAINT DENTINS_FK FOREIGN KEY (INSID) REFERENCES insuranceplans (INSID)
);

CREATE TABLE projects (
    PROJID INTEGER NOT NULL,
    NAME VARCHAR(32) NOT NULL,
    BUDGET DECIMAL(11,2) NOT NULL,
    CONSTRAINT PROJS_PK PRIMARY KEY (PROJID)
);

CREATE TABLE project_reviewer (
    PROJID INTEGER REFERENCES projects NOT NULL,
    REVIEWER INTEGER REFERENCES persons NOT NULL
);

CREATE TABLE project_member (
    PROJID INTEGER NOT NULL,
    MEMBER INTEGER NOT NULL
);

CREATE TABLE employee_phoneno_type (
    EMPID INTEGER REFERENCES persons NOT NULL,
    PHONENO VARCHAR(16) NOT NULL,
    TYPE VARCHAR(16) NOT NULL
);

ALTER TABLE project_reviewer 
    ADD CONSTRAINT PR_PROJ_FK FOREIGN KEY
        (PROJID) REFERENCES projects(PROJID);
ALTER TABLE project_reviewer 
    ADD CONSTRAINT PR_REV_FK FOREIGN KEY
        (REVIEWER) REFERENCES persons(PERSONID)
;

ALTER TABLE departments 
    ADD CONSTRAINT EMP_MO_FK FOREIGN KEY
        (EMP_OF_THE_MONTH) REFERENCES persons(PERSONID)
;

disconnect;
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE orm PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 2.0//EN" "http://java.sun.com/dtd/orm_2_0.dtd";>
<!--
This file contains the schema information when an implementation
has application identity.

Inheritance mapping: 
Separate table for each class in the inheritance hierarchy.
Inheritance strategy: new-table for all classes
-->
<orm>
    <package name="org.apache.jdo.tck.pc.company">

        <class name="Company" table="companies">
            <field name="companyid" column="ID" primary-key="true"/>
            <field name="name" column="NAME"/>
            <field name="founded" column="FOUNDEDDATE"/>
            <field name="address">
                <embedded null-indicator-column="COUNTRY">
                    <field name="addrid" column="ADDRID"/>
                    <field name="street" column="STREET"/>
                    <field name="city" column="CITY"/>
                    <field name="state" column="STATE"/>
                    <field name="zipcode" column="ZIPCODE"/>
                    <field name="country" column="COUNTRY"/>
                </embedded>
            </field>
            <field name="departments" mapped-by="company"/>
        </class>

        <class name="Department" table="departments">
            <field name="deptid" column="ID" primary-key="true"/>
            <field name="name" column="NAME"/>
            <field name="company" column="COMPANYID" foreign-key="true"/>
            <field name="employees" mapped-by="department"/>
            <field name="fundedEmps" mapped-by="fundingDept"/>
            <field name="employeeOfTheMonth" column="EMP_OF_THE_MONTH"/>
        </class>

        <class name="PartTimeEmployee" table="parttimeemployees">
            <inheritance strategy="new-table">
                <join column="PERSONID"/>
            </inheritance>
            <field name="wage" column="WAGE"/>
        </class>

        <class name="FullTimeEmployee" table="fulltimeemployees">
            <inheritance strategy="new-table">
                <join column="PERSONID"/>
            </inheritance>
            <field name="salary" column="SALARY"/>
        </class>

        <class name="Employee" table="employees">
            <inheritance strategy="new-table">
                <join column="PERSONID"/>
            </inheritance>
            <field name="hiredate" column="HIREDATE"/>
            <field name="weeklyhours" column="WEEKLYHOURS"/>
            <field name="dentalInsurance" mapped-by="employee"/>
            <field name="medicalInsurance" mapped-by="employee"/>
            <field name="department" column="DEPARTMENT">
                        <foreign-key/>
            </field>
            <field name="fundingDept" column="FUNDINGDEPT">
                        <foreign-key/>
            </field>
            <field name="manager" column="MANAGER">
                        <foreign-key/>
            </field>
            <field name="mentor" column="MENTOR">
                        <foreign-key/>
            </field>
            <field name="protege" mapped-by="mentor"/>
            <field name="hradvisor" column="HRADVISOR">
                        <foreign-key/>
            </field>
            <field name="reviewedProjects" mapped-by="reviewers">
            </field>
            <field name="projects" mapped-by="members"/>
            <field name="team" mapped-by="manager"/>
            <field name="hradvisees" mapped-by="hradvisor"/>
        </class>

        <class name="Person" table="persons">
            <inheritance strategy="new-table"/>
            <field name="personid" column="PERSONID" primary-key="true"/>
            <field name="firstname" column="FIRSTNAME"/>
            <field name="lastname" column="LASTNAME"/>
            <field name="middlename" column="MIDDLENAME"/>
            <field name="address">
                <embedded null-indicator-column="COUNTRY">
                    <field name="addrid" column="ADDRID"/>
                    <field name="street" column="STREET"/>
                    <field name="city" column="CITY"/>
                    <field name="state" column="STATE"/>
                    <field name="zipcode" column="ZIPCODE"/>
                    <field name="country" column="COUNTRY"/>
                </embedded>
            </field>
            <field name="phoneNumbers" table="employee_phoneno_type" >
                <join column="EMPID"/>
                <key column="TYPE"/>
                <value column="PHONENO"/>
            </field>
        </class>

        <class name="Insurance" table="insuranceplans">
            <inheritance strategy="new-table"/>
            <field name="insid" column="INSID" primary-key="true"/>
            <field name="carrier" column="CARRIER"/>
            <field name="employee" column="EMPLOYEE">
                 <foreign-key/>
            </field>
        </class>

        <class name="DentalInsurance" table="dentalinsurance">
            <inheritance strategy="new-table">
                <join column="INSID"/>
            </inheritance>
            <field name="lifetimeOrthoBenefit" column="LIFETIME_ORTHO_BENEFIT"/>
        </class>

        <class name="MedicalInsurance" table="medicalinsurance">
            <inheritance strategy="new-table">
                <join column="INSID"/>
            </inheritance>
            <field name="planType" column="PLANTYPE"/>
        </class>

        <class name="Project" table="projects">
            <field name="projid" column="PROJID" primary-key="true"/>
            <field name="name" column="NAME"/>
            <field name="budget">
               <column name="BUDGET" jdbc-type="DECIMAL" length="11" scale="2"/>
            </field>
            <field name="reviewers" table="project_reviewer">
                <join column="PROJID">
                    <foreign-key name="PR_PROJ_FK"/>
                </join>
                <element column="REVIEWER">
                    <foreign-key name="PR_REV_FK"/>
                </element>
            </field>
            <field name="members" table="project_member">
                <join column="PROJID"/>
                <element column="MEMBER"/>
            </field>
        </class>
    </package>
</orm>

Reply via email to