I'm trying to use a map relationship that has a database setup that is a bit different than all examples that I have seen.
Parent Table SBT_BGT_STRGRP_HRS (see mapping document for details)
has a composite id of two ints. One of these ints is a foreign key to the child table.
Child Table SBT_OPER_HRS_NM
key = foreign key from parent table (I am attempting to use this as the key to my map)
child = OPER_HRS_NM (I am attempting to use this as the value in my map)
The error that I am getting (see below) implies that my key must use both parts of the primary key, however, only one part of the primary key is the foreign key into my child table.
From my hibernate experience, I'm starting to get the idea that composite id's are not reccommended.
Any ideas?
Hibernate version:2.0
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.kohls.sb.sb.common.entity">
<class name="DayType" table="SBT_BGT_STRGRP_HRS">
<composite-id>
<key-property name="groupId" column="STR_BGT_GRP_ID" type="java.lang.Integer"/>
<key-property name="hoursId" column="OPER_HRS_ID" type="java.lang.Integer"/>
</composite-id>
<property name="operatingHoursCode" column="OPER_HRS_CDE" type="java.lang.Integer" not-null="true"/>
<map name="dayNames" table="SBT_OPER_HRS_NM">
<key column="OPER_HRS_ID"/>
<index column="OPER_HRS_ID" type="java.lang.Integer"/>
<element column="OPER_HRS_NM" type="string"/>
</map>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
[2005-02-07 13:00:11,424] [main] ERROR - Failed to initalize: class com.kohls.sb.sb.server.dao.SBPersistFactory configuration exception Foreign key (SBT_OPER_HRS_NM [OPER_HRS_ID])) must have same number of columns as the referenced primary key (SBT_BGT_STRGRP_HRS [STR_BGT_GRP_ID,OPER_HRS_ID]) -com.kohls.sb.sb.server.dao.SBPersistFactory
net.sf.hibernate.MappingException: Foreign key (SBT_OPER_HRS_NM [OPER_HRS_ID])) must have same number of columns as the referenced primary key (SBT_BGT_STRGRP_HRS [STR_BGT_GRP_ID,OPER_HRS_ID])
at net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:60)
at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:667)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:761)
at com.kohls.sb.sb.server.dao.SBPersistFactory.init(SBPersistFactory.java:34)
at com.kohls.sb.sb.server.dao.SBPersistFactory.getInstance(SBPersistFactory.java:70)
at com.kohls.sb.sb.server.dao.BaseDao.findAll(BaseDao.java:39)
at com.kohls.sb.sb.server.facade.BudgetFacadeBean.findAll(BudgetFacadeBean.java:214)
at com.kohls.sb.sb.server.facade.BudgetFacadeBean_vg38e_EOImpl.findAll(BudgetFacadeBean_vg38e_EOImpl.java:584)
at com.kohls.sb.sb.server.application.SBServerCache.initialize(SBServerCache.java:63)
at com.kohls.sb.sb.server.application.SBServerCache.<init>(SBServerCache.java:43)
at com.kohls.sb.sb.server.application.SBServerCache.<clinit>(SBServerCache.java:271)
at com.kohls.sb.sb.server.facade.BudgetFacadeBean.ejbCreate(BudgetFacadeBean.java:78)
at com.kohls.sb.sb.server.facade.BudgetFacadeBean_vg38e_Impl.ejbCreate(BudgetFacadeBean_vg38e_Impl.java:135)
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 weblogic.ejb20.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:172)
at weblogic.ejb20.pool.Pool.createInitialBeans(Pool.java:254)
at weblogic.ejb20.manager.StatelessManager.initializePool(StatelessManager.java:376)
at weblogic.ejb20.deployer.EJBDeployer.initializePools(EJBDeployer.java:1530)
at weblogic.ejb20.deployer.EJBDeployer.start(EJBDeployer.java:1397)
at weblogic.ejb20.deployer.EJBModule.start(EJBModule.java:668)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2022)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2063)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2010)
at weblogic.management.deploy.slave.SlaveDeployer$Application.setActivation(SlaveDeployer.java:3108)
at weblogic.management.deploy.slave.SlaveDeployer.setActivationStateForAllApplications(SlaveDeployer.java:1656)
at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:372)
at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229)
at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:964)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:359)
at weblogic.Server.main(Server.java:32)
Name and version of the database you are using:
DB2
|