-->
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: org.hibernate.MappingException
PostPosted: Mon Mar 08, 2010 3:48 am 
Newbie

Joined: Mon Mar 08, 2010 3:44 am
Posts: 8
Hello.

I am checking the forum and trying to find solutions to my problem but I am begginer with Hibernate and I am a little bit lost.

I'm getting the next exception:
Code:
ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Foreign key (FK9AAD5D7317D2C9DE:T_NODO_ATRIBUTOS [ID_ESTRUCTURA])) must have same number of columns as the referenced primary key (T_NODOS_ESTRUCT_XML [ID_ESTRUCTURA,ID_NODO])
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1403)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
   at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
   at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
   at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
   at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
   at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
   at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
   at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
   at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
   at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
   at org.mortbay.jetty.Server.doStart(Server.java:217)
   at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
   at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:188)
   at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:147)
   at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:219)
   at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:86)
   at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:377)
   at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:938)
   at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:690)
   at com.google.gwt.dev.DevMode.main(DevMode.java:251)
Caused by: org.hibernate.MappingException: Foreign key (FK9AAD5D7317D2C9DE:T_NODO_ATRIBUTOS [ID_ESTRUCTURA])) must have same number of columns as the referenced primary key (T_NODOS_ESTRUCT_XML [ID_ESTRUCTURA,ID_NODO])
   at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:113)
   at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:96)
   at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1310)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1217)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1162)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
   at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$5.run(AbstractAutowireCapableBeanFactory.java:1450)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1448)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)
   ... 31 more



And my actual code is the next:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 05-mar-2010 11:01:06 by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
    <class name="TNodosEstructXml" table="T_NODOS_ESTRUCT_XML">
        <composite-id name="id" class="TNodosEstructXmlId">
            <key-property name="idEstructura" type="big_decimal">
                <column name="ID_ESTRUCTURA" precision="22" scale="0" />
            </key-property>
            <key-property name="idNodo" type="big_decimal">
                <column name="ID_NODO" precision="22" scale="0" />
            </key-property>
        </composite-id>
        <many-to-one name="TEstructurasXml" class="TEstructurasXml" update="false" insert="false" fetch="select">
            <column name="ID_ESTRUCTURA" precision="22" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="TNodosEstructXml" class="TNodosEstructXml" fetch="select">
            <column name="ID_ESTRUCTURA_PADRE" precision="22" scale="0" not-null="true" />
            <column name="ID_NODO_PADRE" precision="22" scale="0" not-null="true" />
        </many-to-one>
        <property name="nombreNodo" type="string">
            <column name="NOMBRE_NODO" length="50" not-null="true" />
        </property>
        <property name="indDatos" type="char">
            <column name="IND_DATOS" length="1" not-null="true" />
        </property>
        <property name="indMultiplicidad" type="char">
            <column name="IND_MULTIPLICIDAD" length="1" not-null="true" />
        </property>
        <set name="TNodosEstructXmls" inverse="true" lazy="true" table="T_NODOS_ESTRUCT_XML" fetch="select">
            <key>
                <column name="ID_ESTRUCTURA_PADRE" precision="22" scale="0" not-null="true" />
                <column name="ID_NODO_PADRE" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="TNodosEstructXml" />
        </set>
        <set name="TAtributoses" inverse="false" lazy="true" table="T_NODO_ATRIBUTOS" fetch="select">
            <key>
                <column name="ID_ESTRUCTURA" precision="22" scale="0" not-null="true" />
                <column name="ID_NODO" precision="22" scale="0" not-null="true" />
            </key>
            <many-to-many entity-name="TAtributos">
                <column name="ID_ATRIBUTO" precision="22" scale="0" not-null="true" />
            </many-to-many>
        </set>
    </class>
</hibernate-mapping>


I don't see where is the problem.
Can you help me?, thanks ;)


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.