-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error mapping 2 tables with composite keys
PostPosted: Thu Sep 09, 2004 6:56 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
I am getting an error mapping composite keys. Please advise. Mapping files are below.

Hibernate version:
Version 2
Mapping documents:

I have one table
<hibernate-mapping package="com.xxx.business.domain">
<class
name="PlanPkgOptionValue"
table="PLAN_PKG_OPTION_VALUE"
>
<composite-id name="id" class="PlanPkgOptionValuePK">
<key-many-to-one
name="planPkgOption"
class="PlanPkgOption"
>
<column name="PLAN_PACKAGE_ID"/>
<column name="OPTION_VALUE_ID"/>
</key-many-to-one>
<key-many-to-one
name="optionValue"
class="OptionValue"
column="OPTION_VALUE_ID"
/>
</composite-id>

and another related table
<hibernate-mapping package="com.xxx.business.domain">
<class
name="PlanPkgOdometerOptVal"
table="PLAN_PKG_ODOMETER_OPT_VAL"
>
<composite-id>
<key-many-to-one name="optionValue" class="PlanPkgOptionValue">
<column name="OPTION_VALUE_ID"/>
<column name="PLAN_PACKAGE_ID"/>
<column name="OPTION_ID"/>
</key-many-to-one>
<key-many-to-one
name="odometer"
class="PlanPkgOdometer"
column="ODOMETER_ID"
/>
</composite-id>
Full stack trace of any exception that occurs:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in resource [/WEB-INF/applicationContext.xml] of ServletContext: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: Foreign key (PLAN_PKG_ODOMETER_OPT_VAL [OPTION_VALUE_ID,PLAN_PACKAGE_ID,OPTION_ID])) must have same number of columns as the referenced primary key (PLAN_PKG_OPTION_VALUE [PLAN_PACKAGE_ID,OPTION_VALUE_ID])
net.sf.hibernate.MappingException: Foreign key (PLAN_PKG_ODOMETER_OPT_VAL [OPTION_VALUE_ID,PLAN_PACKAGE_ID,OPTION_ID])) must have same number of columns as the referenced primary key (PLAN_PKG_OPTION_VALUE [PLAN_PACKAGE_ID,OPTION_VALUE_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 org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:467)
at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:405)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:991)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:208)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:224)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:284)
at org.springframework.web.context.support.XmlWebApplicationContext.refresh(XmlWebApplicationContext.java:131)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:156)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:97)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
at org.mortbay.jetty.servlet.WebApplicationContext.start(WebApplicationContext.java:439)
at org.mortbay.http.HttpServer.start(HttpServer.java:663)
at com.iw.plugins.jettyrunner.PluginRunner.launch(PluginRunner.java:231)
at com.iw.plugins.jettyrunner.PluginRunner.main(PluginRunner.java:135)

Name and version of the database you are using:
Oracle 8i


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.