Hibernate version:
2.1.6
Mapping documents:
Excerpts included in body
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
net.sf.hibernate.MappingException: collection foreign key mapping has wrong number of columns: com.uprr.app.qts.domain.model.Equipment.rateProposalEquipment type: com.uprr.app.qts.domain.model.EquipmentSubGroupId
at net.sf.hibernate.mapping.Collection.validate(Collection.java:248)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:621)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:785)
at com.uprr.app.qts.domain.util.HibernateUtil.<clinit>(HibernateUtil.java:35)
at com.uprr.app.qts.ejb.session.rateproposal.RateProposalServiceEJB.getRequestor(RateProposalServiceEJB.java:341)
at com.uprr.app.qts.ejb.session.rateproposal.RateProposalServiceEJB_l9nfh6_ELOImpl.getRequestor(RateProposalServiceEJB_l9nfh6_ELOImpl.java:241)
at com.uprr.app.qts.delegates.RateProposalDelegate.getRequestor(RateProposalDelegate.java:113)
at com.uprr.app.qts.webapp.action.QtsAction.getContactInformation(QtsAction.java:226)
at com.uprr.app.qts.webapp.action.QtsAction.getUserProfile(QtsAction.java:141)
at com.uprr.app.qts.webapp.action.raterequest.RateRequestMainAction.perform(RateRequestMainAction.java:77)
at org.apache.struts.action.Action.execute(Action.java:420)
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.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:262)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:198)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2678)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2412)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:140)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:121)
Name and version of the database you are using:
Oracle 8
The generated SQL (show_sql=true):
N/A [mapping exception]
Debug level Hibernate log excerpt:
see stack trace...
OK, I figured this out, I *think*. I changed the mapping in Equipment.hbm.xml so that the key to the collection also had a composite key class, since the collection is owned by an entity with a composite key (Equipment). What's strange here is that this changes the entity referred to by the columns in the mapping from the RateProposal to the Equipment columns...?!?!?! Here's the Equipment.hbm.xml mapping, and I'm not getting an exception anymore:
Code:
<set
name="rateProposalEquipment"
lazy="false"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
>
<column
name="MKTG_EQMT_GRP_ID"
not-null="true"
/>
<column
name="MKTG_EQMT_SGRP_ID"
not-null="true"
/>
</key>
<one-to-many
class="com.uprr.app.qts.domain.model.RateProposalEquipment"
/>
</set>
What doesn't seem intuitive to me is that the <key> element *used* to refer to the RateProposal class and it's key column, RATE_PRPL_ID, and now has switched to refer to the Equipment class and its 2 key columns. My other code for this sort of many-to-many rendering with an intervening link entity has mappings in the analogous class that refer only to the RateProposal. Are these mappings incorrect?
For ex., here's the mapping for the rateProposalParties in Party.hbm.xml, which is analogous to the Equipment.hbm.xml set mapping shown above, the only difference being that Party doesn't have a composite key class while Equipment does. I have been using code like this Party example without incident, and while there are no entities with composite keys, the key column in this set mapping refers to the RateProposal class, not the Party class; it's the Party class that would be the analog of the 2 column Equipment class in my composite key example above. Is this wrong?:
Code:
<set
name="rateProposalParties"
lazy="false"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
>
<column
name="RATE_PRPL_ID"
not-null="true"
/>
</key>
<one-to-many
class="com.uprr.app.qts.domain.model.RateProposalParty"
/>
</set>
Thanks, in advance!
-=j=-