-->
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.  [ 2 posts ] 
Author Message
 Post subject: composite-id and association to tables with simple id
PostPosted: Thu Mar 31, 2005 5:05 am 
Newbie

Joined: Thu Mar 31, 2005 4:15 am
Posts: 4
I've got a problem.
I can't bind two tables. In one ( parameter ) I've got composite-id.
All parameters with the same RESID have the same paths ( they can have more then one path ). They can have diferent versions but all with the same RESID have one path.
Secound table has field LEAF <<fk>> that contains resid of parameter.

I have exception during geting parameter object:
MappingException: Foreign key (REQUIREMENT_PATH [LEAF])) must have same number of columns as the referenced primary key (REQUIREMENT_PARAMETER [RESID,HISTORY,VERSION])

What I can do?
How to resolve that problem?
How to change mapping?
Modification structure of tables is dificult because it is working now.
I need REQUIREMENT_PATH table for other objects.
My tables like that:
Code:
       |-----------------|          |-----------------------|
       |REQUIREMENT_PATH |          | REQUIREMENT_PARAMETER |
       |-----------------|          |-----------------------|
       |LEAF <<fk>>      |          | RESID <<pk>>          |
       |PATH     <<pk>>  |          | VERSION <<pk>>        |
       |TYPE             |          | HISTORY <<pk>>        |
       |FLAG             |          | PARAMDEFID            |
       |-----------------|          | PARAMETERVALUE        |
                                    |-----------------------|


Hibernate version:
2.1.7
Mapping documents:
Code:
<class  name="RequirementParameterDTO" table="REQUIREMENT_PARAMETER">
          <composite-id>
                    <key-property column="RESID"   length="10"  name="id" type="string" />
                    <key-property column="HISTORY" length="10"  name="history" type="string" />
                    <key-property column="VERSION" length="10"  name="version" type="string" />
            </composite-id>
         
            <property column="PARAMDEFID" length="10" name="parameterDefinitionId" not-null="true" type="string"  />
          <property column="PARAMETERVALUE" length="2048" name="parameterValue" not-null="false" type="string"  />
          <set name="pathSet" table="REQUIREMENT_PATH" lazy="false" batch-size="100">
                 <key column="LEAF"/>
                 <element column="PATH" type="string"/>
            </set>
       </class>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Code:
net.sf.hibernate.MappingException: Foreign key (REQUIREMENT_PATH [LEAF])) must have same number of columns as the referenced primary key (REQUIREMENT_PARAMETER [RESID,HISTORY,VERSION])
   at net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:67)
   at net.sf.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:705)
   at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:680)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:798)
   at com.examle.common.util.HibernateUtil.<clinit>(HibernateUtil.java:28)
   at com.examle.logic.user.UserLogic.loginUser(UserLogic.java:444)
   at com.examle.ws.requirement.RequirementServiceImpl.login(RequirementServiceImpl.java:225)
   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:585)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:382)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:279)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:319)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:450)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:637)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:301)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)
- org.apache.axis.i18n.resource::handleGetObject(toAxisFault00)
- Mapping Exception to AxisFault
java.lang.reflect.InvocationTargetException
   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:585)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:382)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:279)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:319)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:450)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:637)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:301)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ExceptionInInitializerError
   at com.examle.common.util.HibernateUtil.<clinit>(HibernateUtil.java:31)
   at com.examle.logic.user.UserLogic.loginUser(UserLogic.java:444)
   at com.examle.ws.requirement.RequirementServiceImpl.login(RequirementServiceImpl.java:225)
   ... 30 more
Caused by: net.sf.hibernate.MappingException: Foreign key (REQUIREMENT_PATH [LEAF])) must have same number of columns as the referenced primary key (REQUIREMENT_PARAMETER [RESID,HISTORY,VERSION])
   at net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:67)
   at net.sf.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:705)
   at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:680)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:798)
   at com.examle.common.util.HibernateUtil.<clinit>(HibernateUtil.java:28)
   ... 32 more

Name and version of the database you are using:
Oracle9
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 11:25 am 
Newbie

Joined: Fri Jan 16, 2004 2:37 am
Posts: 5
Location: Columbus, Ohio
The error means that your FK in REQUIREMENT_PATH, leaf? needs to match a the PK of the 'containing' the set. What are your PK constraints like? Post the DDL for the DB (at least those two tables) I can give you a hand.


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

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.