-->
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: Problem Hibernate
PostPosted: Thu Sep 27, 2007 3:46 pm 
Newbie

Joined: Thu Sep 27, 2007 3:39 pm
Posts: 1
Helo!

I am with a composed problem with foreign key.

Banco
osm_ordem_serv_man
- osm_nu_osm pk
- osmcd_veiculo fk
- osm_cd_emp_veiculo fk

vcl_veiculo
- vcl_cd_empresa pk
- vcl_cd_veiculo pk

Code:
    <class name="br.bean.Osm" table="osm_ordem_serv_man"> 
           
            <id name="numero" column="osm_nu_osm"/> 
         
      <many-to-one name="veiculo" class="br.bean.Veiculo" 
                insert="false" update="false"> 
                <column name="osm_cd_veiculo"/> 
               <column name="osm_cd_emp_veic"/> 
         </many-to-one> 
     ...


Code:
<class name="br.bean.Veiculo" table="vcl_veiculo">
        <!--
        <id name="codigo" column="vcl_cd_veiculo"/>
        <property name="codigoEmpresa" column="vcl_cd_empresa" />
        -->
       
        <composite-id name="compositeID" class="br.bean.VeiculoID">
             <key-many-to-one name="veiculo"
                column="vcl_cd_veiculo"
                 class="br.bean.Veiculo"/>
             <key-many-to-one name="empresa"
                 column="vcl_cd_empresa"
                 class="br.bean.Empresa"/>
        </composite-id>


it gives the following error!

Code:
Initial SessionFactory creation failed.
org.hibernate.MappingException: Foreign key (FK47AECF2FCABA5BA0:vcl_veiculo [vcl_cd_veiculo])) must have same number of columns as the referenced primary key (vcl_veiculo [vcl_cd_veiculo,vcl_cd_empresa])
Exception in thread "main" java.lang.ExceptionInInitializerError
   at br.util.HibernateUtil.<clinit>(HibernateUtil.java:32)
   at br.dao.OsmDAO.excluir(OsmDAO.java:302)
   at br.dao.OsmDAO.main(OsmDAO.java:439)
Caused by: org.hibernate.MappingException: Foreign key (FK47AECF2FCABA5BA0:vcl_veiculo [vcl_cd_veiculo])) must have same number of columns as the referenced primary key (vcl_veiculo [vcl_cd_veiculo,vcl_cd_empresa])
   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:1123)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1062)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1146)
   at br.util.HibernateUtil.<clinit>(HibernateUtil.java:26)
   ... 2 more
Process exited with exit code 1.



they alguem knows as to solve?


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.