I'm trying to use a one-to-one association between my person object and an email address object. The email address object is a subclass of ElectronicAddressVO with a discriminator. The electronic address object has the person id property which is the property that I'm referecning on the person side in my one-to-relationship. However, Hibernate doesn't seem to be able to see this. It seems it's because it's on the super class and not on the subclass. Is this true? If so, is there a way that I can make a one-to-one relationship see the mapped properties on a super class?
Hibernate version:
2.1.6
Mapping documents:
Person Mapping
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="x.x.x.model.sysadmin.PersonVO"
table="ICIS_PERSON"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="personId"
column="PERSON_ID"
type="long"
>
<generator class="sequence">
<param name="sequence">SEQ_ICIS_PERSON</param>
</generator>
</id>
<property
name="firstName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="FIRST_NAME"
/>
<property
name="lastName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="LAST_NAME"
/>
<property
name="middleName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="MIDDLE_NAME"
/>
<property
name="title"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="TITLE"
/>
<property
name="mailCode"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="MAIL_CODE"
/>
<property
name="organizationId"
type="long"
update="true"
insert="true"
access="property"
column="ORGANIZATION_ID"
/>
<property
name="officeId"
type="long"
update="true"
insert="true"
access="property"
column="OFFICE_ID"
/>
<property
name="certificationType"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="CERTIFICATION_TYPE_CODE"
/>
<one-to-one
name="officePhone"
class="x.x.x.model.sysadmin.OfficePhone"
cascade="all"
outer-join="auto"
constrained="false"
/>
<one-to-one
name="faxPhone"
class="x.x.x.model.sysadmin.FaxPhone"
cascade="all"
outer-join="auto"
constrained="false"
/>
<one-to-one
name="emailAddress"
class="x.x.x.model.sysadmin.EmailAddress"
cascade="all"
outer-join="auto"
constrained="false"
property-ref="personId"
/>
</class>
</hibernate-mapping>
Electronic Address mappingCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="x.x.x.model.sysadmin.ElectronicAddressVO"
table="ICIS_PERSON_ELECTRONIC_ADDRESS"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="PERSON_ELECTRONIC_ADDRESS_ID"
type="long"
unsaved-value="0"
>
<generator class="sequence">
<param name="sequence">SEQ_ICIS_PERSON_ELECTRONIC_ADD</param>
</generator>
</id>
<discriminator
column="ELECTRONIC_ADDRESS_TYPE_CODE"
type="string"
/>
<property
name="address"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="ELECTRONIC_ADDRESS_TEXT"
/>
<many-to-one
name="person"
class="x.x.x.model.sysadmin.PersonVO"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="PERSON_ID"
/>
<property
name="type"
type="java.lang.String"
update="false"
insert="false"
access="property"
column="ELECTRONIC_ADDRESS_TYPE_CODE"
/>
<subclass
name="x.x.x.model.sysadmin.EmailAddress"
dynamic-update="true"
dynamic-insert="true"
discriminator-value="EML"
>
</subclass>
</class>
<query name="sysadmin.getAddressById"><![CDATA[
from ElectronicAddressVO address where address.id = :id
]]></query>
</hibernate-mapping>
Full stack trace of any exception that occurs:
net.sf.hibernate.cfg.Configuration: property-ref not found: personId in class: x.x.x.model.sysadmin.EmailAddress
at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:653)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:784)
at xx.x.common.server.dao.hibernate.HibernateSessionManager.intializeSessionFactory(HibernateSessionManager.java:293)
at x.x.x.common.server.dao.hibernate.HibernateSessionManager.<clinit>(HibernateSessionManager.java:370)
at x.x.x.common.server.dao.hibernate.HibernateTemplate.<init>(HibernateTemplate.java:78)
at x.x.x.dao.main.RefDataDAO.getRefDataList(RefDataDAO.java:55)
at x.x.x.main.server.cmd.GetRefDataListCmd.doWork(GetRefDataListCmd.java:43)
at x.x.x.common.server.cmd.BaseCmd.execute(BaseCmd.java:59)
at x.x.x.main.server.ejb.RefDataSB.getRefDataList(RefDataSB.java:44)
at x.x.x.main.server.ejb.RefData_1r0n1r_EOImpl.getRefDataList(RefData_1r0n1r_EOImpl.java:46)
at x.x.x.main.server.ejb.RefData_1r0n1r_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:166)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
at x.x.x.main.server.ejb.RefData_1r0n1r_EOImpl_813_WLStub.getRefDataList(Unknown Source)
at x.x.x.main.ui.RefDataManagerDelegate.getRefDataList(RefDataManagerDelegate.java:50)
at x.x.x.main.ui.RefDataManager.getRefDataList(RefDataManager.java:52)
at x.x.x.sysadmin.ui.action.SaveUserAction.initPageData(SaveUserAction.java:173)
at x.x.x.sysadmin.ui.action.SaveUserAction.loadEditPage(SaveUserAction.java:123)
at x.xx.sysadmin.ui.action.SaveUserAction.execute(SaveUserAction.java:83)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Name and version of the database you are using:
Oracle 9.1 9.2.0.2
The generated SQL (show_sql=true):
(none being generated yet)
Debug level Hibernate log excerpt: