Hi All,
I have the following hierarchy in place.
public interface PartyRole extends Serializable {
public PartyAssociation getPartyAssociation();
public void setPartyAssociation(final PartyAssociation thePartyAssociation);
public PartyRoleType getPartyRoleType();
public void setPartyRoleType(PartyRoleType thePartyRole);
}
public interface PartyApplicantRoleIntf extends PartyRole {
public AccountApplication getAccountApplication();
public void setAccountApplication(final AccountApplication theAccountApplication);
}
public class PossibleOwner implements PartyApplicantRoleIntf {
AccountApplication accountApplication;
PartyAssociation partyAssociation;
ResponsibilityType responsibilityType;
PartyRoleType partyRoleType;
public PossibleOwner() {
}
public PossibleOwner(PartyAssociation thePartyAssociation) {
partyAssociation = thePartyAssociation;
}
public AccountApplication getAccountApplication() {
return accountApplication;
}
public void setAccountApplication(final AccountApplication theAccountApplication) {
this.accountApplication = theAccountApplication;
}
public PartyAssociation getPartyAssociation() {
return partyAssociation;
}
public void setPartyAssociation(final PartyAssociation thePartyAssociation) {
this.partyAssociation = thePartyAssociation;
}
public ResponsibilityType getResponsibilityType() {
return responsibilityType;
}
public void setResponsibilityType(ResponsibilityType responsibilityType) {
this.responsibilityType = responsibilityType;
}
public PartyRoleType getPartyRoleType() {
return partyRoleType;
}
public void setPartyRoleType(PartyRoleType partyRoleType) {
this.partyRoleType = partyRoleType;
}
}
And my hibernate mapping is as follows,
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.vsoftcorp.coresoft.model">
<typedef name="responsibilityType" class="com.vsoftcorp.utils.hibernate.EnumTypeForResponsibilityType">
<param name="enumClass">com.vsoftcorp.coresoft.model.typesafety.ResponsibilityType</param>
<param name="identifierMethod">getValue</param>
<param name="valueOfMethod">valueOf</param>
</typedef>
<typedef name="roleType" class="com.vsoftcorp.utils.hibernate.EnumTypeForRoleType">
<param name="enumClass">com.vsoftcorp.coresoft.utils.RoleTypeName</param>
<param name="identifierMethod">getValue</param>
<param name="valueOfMethod">valueOf</param>
</typedef>
<class name="com.vsoftcorp.coresoft.model.party.PartyRole" table="PARTY_ROLE">
<id type="int">
<column name="UNIQUE_PARTY_ROLE_ID" sql-type="NUMBER" not-null="true"/>
<generator class="sequence">
<param name="sequence">ACCOUNT_APPLICATION_SEQ</param>
</generator>
</id>
<many-to-one name="partyAssociation"
class="com.vsoftcorp.coresoft.model.party.PartyAssociation"
column="UNIQUE_ASSOCIATION_ID" not-null="true"/>
<component name="partyRoleType" class="com.vsoftcorp.coresoft.model.hibernate.PartyRoleType">
<property name="roleType" type="roleType">
<column name="ROLE_TYPE_ID" sql-type="NVARCHAR" />
</property>
</component>
<joined-subclass name="com.vsoftcorp.coresoft.model.party.PartyApplicantRoleIntf" table="PARTY_APPLICANT_ROLE">
<key column="UNIQUE_PARTY_ROLE_ID"/>
<many-to-one name="accountApplication"
class="com.vsoftcorp.coresoft.model.SimpleAccountApplication"
column="UNIQUE_APPLICATION_ID" not-null="true"/>
<joined-subclass name="com.vsoftcorp.coresoft.model.party.PossibleOwner" table="POSSIBLE_OWNER">
<key column="UNIQUE_PARTY_ROLE_ID" />
<property name="responsibilityType" type="responsibilityType">
<column name="RESPONSIBILITY_TYPE" sql-type="NUMBER" />
</property>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
Whats wrong with this mapping? My database structure is as follows,
CREATE TABLE PARTY_ROLE (
UNIQUE_PARTY_ROLE_ID NUMBER(20,0) NOT NULL,
ROLE_TYPE_ID NVARCHAR2(60) NOT NULL,
UNIQUE_ASSOCIATION_ID NUMBER(20,0) NOT NULL,
PRIMARY KEY(UNIQUE_PARTY_ROLE_ID)
)
GO
ALTER TABLE PARTY_ROLE
ADD ( CONSTRAINT PARTY_ROLE_UAID_FK
FOREIGN KEY(UNIQUE_ASSOCIATION_ID)
REFERENCES PARTY_INSTITUTION_ASSOCIATION(UNIQUE_ASSOCIATION_ID) )
GO
ALTER TABLE PARTY_ROLE
ADD ( CONSTRAINT PARTY_ROLE_UPRID_FK
FOREIGN KEY(ROLE_TYPE_ID)
REFERENCES PARTY_ROLE_TYPE(ROLE_TYPE_ID) )
GO
CREATE TABLE PARTY_APPLICANT_ROLE (
UNIQUE_PARTY_ROLE_ID NUMBER(20,0) NOT NULL,
UNIQUE_APPLICATION_ID NUMBER(20,0) NOT NULL,
PRIMARY KEY(UNIQUE_PARTY_ROLE_ID)
)
GO
ALTER TABLE PARTY_APPLICANT_ROLE
ADD ( CONSTRAINT PARTY_APP_ROLE_UPRID_FK
FOREIGN KEY(UNIQUE_PARTY_ROLE_ID)
REFERENCES PARTY_ROLE(UNIQUE_PARTY_ROLE_ID))
GO
CREATE TABLE POSSIBLE_OWNER (
UNIQUE_PARTY_ROLE_ID NUMBER(20,0) NOT NULL,
RESPONSIBILITY_TYPE NUMBER(20,0) NULL,
PRIMARY KEY(UNIQUE_PARTY_ROLE_ID)
)
GO
ALTER TABLE POSSIBLE_OWNER
ADD ( CONSTRAINT POSSIBLE_OWNER_UAID_UPRID_FK
FOREIGN KEY(UNIQUE_PARTY_ROLE_ID)
REFERENCES PARTY_APPLICANT_ROLE(UNIQUE_PARTY_ROLE_ID) )
GO
The UNIQUE_APPLICATION_ID in PARTY_APPLICANT_ROLE is foreign key to another table ACCOUNT_APPLICATION's primary key column.
If i try to get a PossibleOwner for the given ACCOUNT_APPLICATION id the query gives me "Invalid column name" Error.
Let me know what is the problem with deep inheritance of this sort.
|