Does any one know of any issues with one-to-one relationships using composite keys? I have 2 objects (Case and Applicant) using the same composite key object (DocketNumberKey). I am able to retrieve both of these objects independently. However, when I nest one object within the other, I get the exception listed below.
One unusual thing to note here: both of these objects map back to the same table. The schema I have to go against belongs to a legacy application and the table is being used to hold both types of information (reworking the table structure is not an option at this time). I was thinking this could have something to do with it, but as I said, I can retrieve these objects just fine independently, so I'm not sure.
Here's what I'm using:
Hibernate 2.1.2
Oracle 9.2
JBoss 3.2.3
Windows XP Pro
Here are the mappings (I'm using xdoclet to generate these):
------------------------------------------------------
CASE:
<?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="org.arbfile.util.olf.model.Case"
table="a_applicant"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="id"
class="org.arbfile.util.olf.model.DocketNumberKey"
>
<key-property
name="program"
type="string"
column="PROGRAM"
/>
<key-property
name="branch"
type="string"
column="BRANCH"
/>
<key-property
name="sequenceNumber"
type="string"
column="SEQUENCE_NO"
/>
<key-property
name="year"
type="string"
column="YEAR"
/>
<key-property
name="counterClaimNumber"
type="string"
column="CCLAIMNUMB"
/>
</composite-id>
<one-to-one
name="applicant"
class="org.arbfile.util.olf.model.Applicant"
cascade="none"
outer-join="auto"
constrained="false"
/>
<property
name="docketNo"
type="string"
update="true"
insert="true"
column="docket_no"
/>
<property
name="dateReceived"
type="date"
update="true"
insert="true"
column="date_received"
/>
<property
name="lossDate"
type="date"
update="true"
insert="true"
column="losaccdate"
/>
<property
name="lossCity"
type="string"
update="true"
insert="true"
column="losacccity"
/>
<property
name="lossState"
type="string"
update="true"
insert="true"
column="losaccstate"
/>
<property
name="hearingYear"
type="string"
update="true"
insert="true"
column="hearyear"
/>
<property
name="hearingPeriod"
type="integer"
update="true"
insert="true"
column="hearperiod"
/>
<property
name="hearingType"
type="string"
update="true"
insert="true"
column="hearing_type"
/>
<property
name="status"
type="string"
update="true"
insert="true"
column="status"
/>
<property
name="closeType"
type="string"
update="true"
insert="true"
column="clotype"
/>
<property
name="closeDate"
type="date"
update="true"
insert="true"
column="closedate"
/>
<property
name="panelMemberCode1"
type="string"
update="true"
insert="true"
column="pm_code"
/>
<property
name="panelMemberCode2"
type="string"
update="true"
insert="true"
column="pm_code2"
/>
<property
name="panelMemberCode3"
type="string"
update="true"
insert="true"
column="pm_code3"
/>
<property
name="defermentChallenge"
type="string"
update="true"
insert="true"
column="defchall"
/>
<property
name="referenceNumber"
type="string"
update="true"
insert="true"
column="refno"
/>
<property
name="liabilityOnly"
type="string"
update="true"
insert="true"
column="liability_only"
/>
<property
name="voidDecision"
type="string"
update="true"
insert="true"
column="void_decision"
/>
<property
name="voidReason"
type="string"
update="true"
insert="true"
column="voidreason"
/>
<property
name="prehearingReportReviewed"
type="string"
update="true"
insert="true"
column="review_prehear_report"
/>
<property
name="fileRetainedAtHearing"
type="string"
update="true"
insert="true"
column="retain_hear"
/>
<property
name="respondentCount"
type="integer"
update="true"
insert="true"
column="resp_count"
/>
<property
name="problemDecision"
type="string"
update="true"
insert="true"
column="prob_dec"
/>
<property
name="receivedMethodType"
type="string"
update="true"
insert="true"
column="rcvd_method_type"
/>
<property
name="disputeType"
type="string"
update="true"
insert="true"
column="dispute_type"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Case.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
------------------------------------------------------
APPLICANT
<?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="org.arbfile.util.olf.model.Applicant"
table="a_applicant"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="id"
class="org.arbfile.util.olf.model.DocketNumberKey"
>
<key-property
name="program"
type="string"
column="PROGRAM"
/>
<key-property
name="branch"
type="string"
column="BRANCH"
/>
<key-property
name="sequenceNumber"
type="string"
column="SEQUENCE_NO"
/>
<key-property
name="year"
type="string"
column="YEAR"
/>
<key-property
name="counterClaimNumber"
type="string"
column="CCLAIMNUMB"
/>
</composite-id>
<property
name="injuredPartyStatus"
type="string"
update="true"
insert="true"
column="injptystatus"
/>
<property
name="damagesClaimed"
type="big_decimal"
update="true"
insert="true"
column="damclaim"
/>
<property
name="insuredDeductable"
type="big_decimal"
update="true"
insert="true"
column="insded"
/>
<property
name="amountInControversy"
type="big_decimal"
update="true"
insert="true"
column="amtcontroversy"
/>
<property
name="billable"
type="string"
update="true"
insert="true"
column="billable"
/>
<property
name="prepaid"
type="string"
update="true"
insert="true"
column="prepaid"
/>
<property
name="prepaidCheckNumber"
type="string"
update="true"
insert="true"
column="prepaid_checkno"
/>
<property
name="prepaidAmount"
type="big_decimal"
update="true"
insert="true"
column="prepaid_amount"
/>
<property
name="injuredPartyFirstName"
type="string"
update="true"
insert="true"
column="injptyfnam"
/>
<property
name="injuredPartyLastName"
type="string"
update="true"
insert="true"
column="injptylnam"
/>
<property
name="docketNo"
type="string"
update="true"
insert="true"
column="docket_no"
/>
<property
name="coCode"
type="string"
update="true"
insert="true"
column="cocode"
/>
<property
name="subsid"
type="string"
update="true"
insert="true"
column="subsid"
/>
<property
name="locationNumber"
type="string"
update="true"
insert="true"
column="location_no"
/>
<property
name="fileNumber"
type="string"
update="true"
insert="true"
column="cmpfile"
/>
<property
name="insuranceType"
type="string"
update="true"
insert="true"
column="instype"
/>
<property
name="counterClaimSuits"
type="string"
update="true"
insert="true"
column="ccsuits"
/>
<property
name="requestingDeferment"
type="string"
update="true"
insert="true"
column="requestdefer"
/>
<property
name="personalRep"
type="string"
update="true"
insert="true"
column="personalrep"
/>
<property
name="requestNotice"
type="string"
update="true"
insert="true"
column="requestnotice"
/>
<property
name="fileReceived"
type="string"
update="true"
insert="true"
column="file_received"
/>
<property
name="requestThreeMember"
type="string"
update="true"
insert="true"
column="threemem"
/>
<property
name="returnPhoto"
type="string"
update="true"
insert="true"
column="returnphoto"
/>
<property
name="certificationOfService"
type="string"
update="true"
insert="true"
column="certsrv"
/>
<property
name="signatory"
type="string"
update="true"
insert="true"
column="signatory"
/>
<property
name="consenting"
type="string"
update="true"
insert="true"
column="consent"
/>
<property
name="appear"
type="string"
update="true"
insert="true"
column="appear"
/>
<property
name="hearingNoticeBatchYear"
type="string"
update="true"
insert="true"
column="hnbatyear"
/>
<property
name="hearingNoticeBatchNumber"
type="integer"
update="true"
insert="true"
column="hnbatchno"
/>
<property
name="hearingNoticeDate"
type="date"
update="true"
insert="true"
column="hndate"
/>
<property
name="decisionNoticeBatchYear"
type="string"
update="true"
insert="true"
column="decbatyear"
/>
<property
name="decisionNoticeBatchNumber"
type="integer"
update="true"
insert="true"
column="decbatchno"
/>
<property
name="decisionNoticeDate"
type="date"
update="true"
insert="true"
column="decdate"
/>
<property
name="benefits"
type="big_decimal"
update="true"
insert="true"
column="benefits"
/>
<property
name="expenses"
type="big_decimal"
update="true"
insert="true"
column="expense"
/>
<property
name="settlementAmount"
type="big_decimal"
update="true"
insert="true"
column="settleamt"
/>
<property
name="settlementDate"
type="date"
update="true"
insert="true"
column="settledate"
/>
<property
name="paymentAmount"
type="big_decimal"
update="true"
insert="true"
column="payment_amount"
/>
<property
name="contributionSought"
type="big_decimal"
update="true"
insert="true"
column="contribution_sought"
/>
<property
name="legalFeesSought"
type="big_decimal"
update="true"
insert="true"
column="legal_fees_sought"
/>
<property
name="contentions"
type="string"
update="true"
insert="true"
column="contentions"
/>
<property
name="repFirstName"
type="string"
update="true"
insert="true"
column="repfname"
/>
<property
name="repLastName"
type="string"
update="true"
insert="true"
column="replname"
/>
<property
name="repPhone"
type="string"
update="true"
insert="true"
column="rep_phone"
/>
<property
name="insuredFirstName"
type="string"
update="true"
insert="true"
column="insfname"
/>
<property
name="insuredLastName"
type="string"
update="true"
insert="true"
column="inslname"
/>
<property
name="customerBillingCode"
type="string"
update="true"
insert="true"
column="customer_bill"
/>
<property
name="filedByTPA"
type="string"
update="true"
insert="true"
column="filed_by_tpa"
/>
<property
name="TPACoCode"
type="string"
update="true"
insert="true"
column="tpa_cocode"
/>
<property
name="TPASubsid"
type="string"
update="true"
insert="true"
column="tpa_subsid"
/>
<property
name="claimRepId"
type="integer"
update="true"
insert="true"
column="claimrepid"
/>
<property
name="threeMemberWaived"
type="string"
update="true"
insert="true"
column="threemem_waived"
/>
<property
name="lineofInsurance"
type="string"
update="true"
insert="true"
column="line_of_ins"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Applicant.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
------------------------------------------------------
HERE'S THE EXCEPTION:
08:57:22,059 INFO [Environment] Hibernate 2.1.1
08:57:22,075 INFO [Environment] hibernate.properties not found
08:57:22,090 INFO [Environment] using CGLIB reflection optimizer
08:57:22,090 INFO [Configuration] configuring from url: jar:file:/C:/java/jboss-3.2.3/server/af/tmp
/deploy/tmp4351espeedear.ear-contents/espeedejb.jar!/hib_ora.cfg.xml
08:57:22,309 INFO [Configuration] Mapping resource: org/arbfile/util/olf/model/Case.hbm.xml
08:57:22,544 INFO [Binder] Mapping class: org.arbfile.util.olf.model.Case -> a_applicant
08:57:23,231 INFO [Configuration] Mapping resource: org/arbfile/util/olf/model/Applicant.hbm.xml
08:57:23,340 INFO [Binder] Mapping class: org.arbfile.util.olf.model.Applicant -> a_applicant
08:57:23,340 INFO [Configuration] Mapping resource: org/arbfile/util/olf/model/Respondent.hbm.xml
08:57:23,434 INFO [Binder] Mapping class: org.arbfile.util.olf.model.Respondent -> a_respondent
08:57:23,450 INFO [Configuration] Configured SessionFactory: java:comp/env/hibernate/OraSessionFactory
08:57:23,450 INFO [Configuration] processing one-to-many association mappings
08:57:23,466 INFO [Configuration] processing one-to-one association property references
08:57:23,466 INFO [Configuration] processing foreign key constraints
08:57:23,528 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.Oracle9Dialect
08:57:23,528 INFO [SettingsFactory] Use outer join fetching: false
08:57:23,559 INFO [NamingHelper] JNDI InitialContext properties:{}
08:57:23,559 INFO [DatasourceConnectionProvider] Using datasource: java:/espeed
08:57:23,575 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA
environment, use of process level read-write cache is not recommended)
08:57:23,575 INFO [SettingsFactory] Use scrollable result sets: true
08:57:23,575 INFO [SettingsFactory] JDBC 2 max batch size: 15
08:57:23,575 INFO [SettingsFactory] Query language substitutions: {}
08:57:23,575 INFO [SettingsFactory] cache provider: net.sf.ehcache.hibernate.Provider
08:57:23,591 INFO [Configuration] instantiating and configuring caches
08:57:23,653 INFO [SessionFactoryImpl] building session factory
08:57:24,137 INFO [SessionFactoryObjectFactory] Factory name: java:comp/env/hibernate/OraSessionFactory
08:57:24,137 INFO [NamingHelper] JNDI InitialContext properties:{}
08:57:24,137 INFO [NamingHelper] Creating subcontext: hibernate
08:57:24,137 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:comp/env/hibernate/OraSessionFactory
08:57:24,137 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
08:57:24,356 ERROR [SBCaseBean] Error retrieving Case
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of org.arbfile.util.olf.model.Case.setApplicant
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:216)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2137)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:239)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044)
at net.sf.hibernate.impl.SessionImpl.doLoadByObject(SessionImpl.java:1898)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1842)
at org.arbfile.ejb.olf.model.SBCaseBean.getCase(SBCaseBean.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:320)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
at org.jboss.ejb.Container.invoke(Container.java:700)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy220.getCase(Unknown Source)
at org.arbfile.web.olf.decision.DocketNumberEntryAction.getCase(DocketNumberEntryAction.java:139)
at org.arbfile.web.olf.decision.DocketNumberEntryAction.isValid(DocketNumberEntryAction.java:112)
at org.arbfile.web.olf.decision.DocketNumberEntryAction.execute(DocketNumberEntryAction.java:56)
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 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.arbfile.web.filters.KillCacheFilter.doFilter(KillCacheFilter.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.cglib.beans.BulkBeanException
at org.arbfile.util.olf.model.Case$$BulkBeanByCGLIB$$36ee0ff3.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:211)
... 91 more
Caused by: java.lang.ClassCastException
... 93 more
Any help would be appreciated.
Thanks,
John
|