-->
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: probleme de mapping Foreign key one-to-one
PostPosted: Thu Jun 17, 2010 11:24 am 
Regular
Regular

Joined: Wed Jan 28, 2009 8:31 pm
Posts: 54
bonjour a tout
j ai deux tables avec les mêmes cles primaires. Remarque que c est pas moi le dbA et quand je fais l association entre les deux j ai l erreur suivante
Quote:
org.hibernate.MappingException: Foreign key (FKFB4D24995E3F6999:tpp_info [branch_cd,account_cd,client_nbr,ap_seq_nbr])) must have same number of columns as the referenced primary key (TACC_PARTY_NAME [branch_cd,account_cd,client_nbr,ap_seq_nbr])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:90)
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:73)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1263)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
at ca.penson.bpsa.BPSAManagerFactory.<clinit>(BPSAManagerFactory.java:18)
at ca.penson.xml2cra.struts.EditReceiptAction.retrieveAccount(EditReceiptAction.java:720)
at ca.penson.xml2cra.struts.EditReceiptAction.search_onClick(EditReceiptAction.java:830)
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 com.cc.framework.adapter.struts.ActionUtil.handleFormAction(Unknown Source)
at com.cc.framework.adapter.struts.FWAction.handleFormAction(Unknown Source)
at com.cc.framework.adapter.struts.ActionUtil.execute(Unknown Source)
at com.cc.framework.adapter.struts.FWAction.execute(Unknown Source)
at com.cc.framework.adapter.struts.FWAction.execute(Unknown Source)
at com.cc.framework.adapter.struts.RequestProcessorUtil.processAction(Unknown Source)
at com.cc.framework.adapter.struts.FWTilesRequestProcessor.processActionPerform(Unknown Source)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:581)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:420)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
voici mes pojos
Code:
package pojo;
     

import java.io.Serializable;

public class InfoClient implements Serializable{
   /**
    *
    */
   private static final long serialVersionUID = 1L;
   // primary key
   private String branchCd;
   private String accountCd;
   private String clientNbr;
   private Short apSeqNbr;
   private String shortNm;
   private String firstName;
   private String lastName;
   private PartyName partyName;
   public PartyName getPartyName() {
      return partyName;
   }
   public void setPartyName(PartyName partyName) {
      this.partyName = partyName;
   }
   public String getBranchCd() {
      return branchCd;
   }
   public void setBranchCd(String branchCd) {
      this.branchCd = branchCd;
   }
   public String getAccountCd() {
      return accountCd;
   }
   public void setAccountCd(String accountCd) {
      this.accountCd = accountCd;
   }
   public String getClientNbr() {
      return clientNbr;
   }
   public void setClientNbr(String clientNbr) {
      this.clientNbr = clientNbr;
   }
   public Short getApSeqNbr() {
      return apSeqNbr;
   }
   public void setApSeqNbr(Short apSeqNbr) {
      this.apSeqNbr = apSeqNbr;
   }
   public String getShortNm() {
      return shortNm;
   }
   public void setShortNm(String shortNm) {
      this.shortNm = shortNm;
   }
   public String getFirstName() {
      return firstName;
   }
   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }
   public String getLastName() {
      return lastName;
   }
   public void setLastName(String lastName) {
      this.lastName = lastName;
   }
   
   
   @Override
   public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result
            + ((accountCd == null) ? 0 : accountCd.hashCode());
      result = prime * result
            + ((apSeqNbr == null) ? 0 : apSeqNbr.hashCode());
      result = prime * result
            + ((branchCd == null) ? 0 : branchCd.hashCode());
      result = prime * result
            + ((clientNbr == null) ? 0 : clientNbr.hashCode());
      return result;
   }
   @Override
   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      InfoClient other = (InfoClient) obj;
      if (accountCd == null) {
         if (other.accountCd != null)
            return false;
      } else if (!accountCd.equals(other.accountCd))
         return false;
      if (apSeqNbr == null) {
         if (other.apSeqNbr != null)
            return false;
      } else if (!apSeqNbr.equals(other.apSeqNbr))
         return false;
      if (branchCd == null) {
         if (other.branchCd != null)
            return false;
      } else if (!branchCd.equals(other.branchCd))
         return false;
      if (clientNbr == null) {
         if (other.clientNbr != null)
            return false;
      } else if (!clientNbr.equals(other.clientNbr))
         return false;
      return true;
   }
   

}
et
Code:
package pojo;

import java.io.Serializable;

public class PartyName implements Serializable {
   private static final long serialVersionUID = 1L;
   // primary key
   private String branchCd;
   private String accountCd;
   private String clientNbr;
   private Short apSeqNbr;

   // fields
   private String languageCd;
   private String socSecTaxCd;
   private String socSecNbr;
   public String getBranchCd() {
      return branchCd;
   }
   public void setBranchCd(String branchCd) {
      this.branchCd = branchCd;
   }
   public String getAccountCd() {
      return accountCd;
   }
   public void setAccountCd(String accountCd) {
      this.accountCd = accountCd;
   }
   public String getClientNbr() {
      return clientNbr;
   }
   public void setClientNbr(String clientNbr) {
      this.clientNbr = clientNbr;
   }
   public Short getApSeqNbr() {
      return apSeqNbr;
   }
   public void setApSeqNbr(Short apSeqNbr) {
      this.apSeqNbr = apSeqNbr;
   }
   public String getLanguageCd() {
      return languageCd;
   }
   public void setLanguageCd(String languageCd) {
      this.languageCd = languageCd;
   }
   public String getSocSecTaxCd() {
      return socSecTaxCd;
   }
   public void setSocSecTaxCd(String socSecTaxCd) {
      this.socSecTaxCd = socSecTaxCd;
   }
   public String getSocSecNbr() {
      return socSecNbr;
   }
   public void setSocSecNbr(String socSecNbr) {
      this.socSecNbr = socSecNbr;
   }
}

et mes hbm
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="pojo">
   <class name="InfoClient" table="tpp_info">
   <composite-id >
         <key-property
         column="branch_cd"
         length="3"
         name="branchCd"
         type="string"/>
   
      
         <key-property  column="account_cd"
         length="5"
         name="accountCd"
         type="string"/>
            
            <key-property
         column="client_nbr"
         length="4"
         name="clientNbr"
         type="string"/>
         
         
         <key-property
         column="ap_seq_nbr"
         length="5"
         name="apSeqNbr"
         type="java.lang.Short"/>
         
      </composite-id>
      <property
         column="short_nm"
         length="20"
         name="shortNm"
         not-null="false"
         type="string"
       />
      
       <property
         column="first_sps_nm"
         length="20"
         name="firstName"
         not-null="false"
         type="string"
       />
       <property
         column="last_sps_nm"
         length="20"
         name="lastName"
         not-null="false"
         type="string"
       />
      
       [B]<many-to-one name="partyName"
         class="pojo.PartyName"
         cascade="all"
         column="branch_cd,account_cd,client_nbr,ap_seq_nbr"
         unique="true"
         />[/B]
      
      
</class>
</hibernate-mapping>
et
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="pojo">
   <class name="PartyName" table="TACC_PARTY_NAME">
   <composite-id >
         <key-property
         column="branch_cd"
         length="3"
         name="branchCd"
         type="string"/>
   
      
         <key-property  column="account_cd"
         length="5"
         name="accountCd"
         type="string"/>
            
            <key-property
         column="client_nbr"
         length="4"
         name="clientNbr"
         type="string"/>
         
         
         <key-property
         column="ap_seq_nbr"
         length="5"
         name="apSeqNbr"
         type="java.lang.Short"/>
         
      </composite-id>
      <property
         column="language_cd"
         length="1"
         name="languageCd"
         not-null="false"
         type="string"
       />
       <property
         column="soc_sec_tax_cd"
         length="1"
         name="socSecTaxCd"
         not-null="false"
         type="string"
       />
             <property
         column="soc_sec_nbr"
         length="9"
         name="socSecNbr"
         not-null="false"
         type="string"
       />
      
</class>
</hibernate-mapping>


et voici mes ddl
Code:
CREATE TABLE "dbo"."tacc_party_name"
(
   client_nbr char(4) NOT NULL,
   branch_cd char(3) NOT NULL,
   account_cd char(5) NOT NULL,
   ap_seq_nbr smallint NOT NULL,
   action char(1) NOT NULL,
   language_cd char(1),
   soc_sec_tax_cd char(1),
   soc_sec_nbr char(9),
   updt_last_tmstp datetime NOT NULL
)
;
CREATE UNIQUE INDEX tacc_party_name_idc ON "dbo"."tacc_party_name"
(
  client_nbr,
  branch_cd,
  account_cd,
  ap_seq_nbr
)
;



Code:
CREATE TABLE "dbo"."tpp_info"
(
   client_nbr char(4) NOT NULL,
   branch_cd char(3) NOT NULL,
   account_cd char(5) NOT NULL,
   ap_seq_nbr smallint NOT NULL,
   action char(1) NOT NULL,
   first_sps_nm char(20),
   last_sps_nm char(20),
   short_nm char(20),
   record_type_cd char(3) NOT NULL,
   rr_cd char(3),
   updt_last_tmstp datetime NOT NULL
)
;
CREATE UNIQUE INDEX tpp_info_idc ON "dbo"."tpp_info"
(
  client_nbr,
  branch_cd,
  account_cd,
  ap_seq_nbr
)
;

donc il me dit que la clé étrangère devrait être égal
a la clé primaire de l autre table ce qui est le cas.
Donc je vois pas ce qu'il veut.


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.