-->
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: Many-to-one HibernateException
PostPosted: Mon Dec 21, 2009 11:50 am 
Newbie

Joined: Mon Dec 21, 2009 11:27 am
Posts: 1
Hi,
im using Hibernate 3 to save data on an MS SQL database. I`m triying to implement a many-to-one relation between two tables, one with the data (CON_CONSULTA) ans another with a set of detail values ( SVP_SVCPOSTULADOS) and I`m Having the next exception "HibernateException: An association from the table SVP_SVCPOSTULADOS refers to an unmapped class: short":

[DEBUG] 21/12/2009 11:55:15 Configuration:1285 - Preparing to build session factory with filters : {}
[DEBUG] 21/12/2009 11:55:15 Configuration:1120 - processing extends queue
[DEBUG] 21/12/2009 11:55:15 Configuration:1124 - processing collection mappings
[DEBUG] 21/12/2009 11:55:15 CollectionSecondPass:41 - Second pass for collection: com.test.portlet.contactos.model.ConsultaHibernate.svcPostulados
[INFO ] 21/12/2009 11:55:15 HbmBinder:2385 - Mapping collection: com.test.portlet.contactos.model.ConsultaHibernate.svcPostulados -> SVP_SVCPOSTULADOS
[DEBUG] 21/12/2009 11:55:15 CollectionSecondPass:57 - Mapped collection key: CON_ID_CONSULTA, one-to-many: com.test.portlet.contactos.model.SvcPostuladosHibernate
[DEBUG] 21/12/2009 11:55:15 Configuration:1135 - processing native query and ResultSetMapping mappings
[DEBUG] 21/12/2009 11:55:15 Configuration:1143 - processing association property references
[DEBUG] 21/12/2009 11:55:15 Configuration:1165 - processing foreign key constraints
[DEBUG] 21/12/2009 11:55:15 Configuration:1248 - resolving reference to class: short
[DEBUG] 21/12/2009 11:55:15 AbstractObjectDAO:41 - HibernateException: An association from the table SVP_SVCPOSTULADOS refers to an unmapped class: short
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:132 - getMessage(es_ES,unhandledException)
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:224 - loadLocale(es_ES)
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:246 - Loading resource 'org/apache/struts/action/ActionResources_es_ES.properties'
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:271 - Loading resource completed
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:224 - loadLocale(es)
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:246 - Loading resource 'org/apache/struts/action/ActionResources_es.properties'
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:271 - Loading resource completed
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:224 - loadLocale()
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:246 - Loading resource 'org/apache/struts/action/ActionResources.properties'
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:271 - Loading resource completed
[DEBUG] 21/12/2009 11:55:15 PropertyMessageResources:284 - Saving message key '.initProcessor

my implementation is as follows:
hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
   
<hibernate-configuration>
   <session-factory>
      <property name="connection.datasource">java:comp/env/jdbc/test_data</property>
      <property name="show_sql">true</property>
      <mapping resource="consulta.hbm.xml"/>
      <mapping resource="svcPostulados.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


consulta.hbm.xml

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">
<hibernate-mapping>       
    <class name="com.test.portlet.contactos.model.ConsultaHibernate" table="CON_CONSULTA">
        <comment></comment>
        <id name="id" type="short">
            <column name="CON_ID_CONSULTA" />
            <generator class="identity"/>
        </id>
                     ....
      <set name="svcPostulados" lazy="true" inverse="true">
            <key column="CON_ID_CONSULTA"/>
            <one-to-many class="com.test.portlet.contactos.model.SvcPostuladosHibernate"/>
        </set>   

   </class>
</hibernate-mapping>


ConsultaHibernate.java
Code:
public class ConsultaHibernate {
   static org.apache.log4j.Logger m_logger = org.apache.log4j.Logger.getLogger("com.test.portlet.contactos.model.ConsultaHibernate");

   private short id = (short) 0L;
   
   private Set<SvcPostuladosHibernate> svcPostulados = null;

   public ConsultaHibernate() {
         ...........
      setSvcPostulados(null);
      
   }
   
   .....................

   public Set<SvcPostuladosHibernate> getSvcPostulados() {
      return svcPostulados;
   }

   public void setSvcPostulados(Set<SvcPostuladosHibernate> svcPostulados) {
      this.svcPostulados = svcPostulados;
   }
   

}


svcPostulados.hbm.xml
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">
<hibernate-mapping>       
   <class name="com.test.portlet.contactos.model.SvcPostuladosHibernate" table="SVP_SVCPOSTULADOS">
        <comment></comment>
        <id name="id" type="short">
            <column name="SVP_ID_SVCPOSTULADOS" />
            <generator class="identity"/>
        </id>
        <property name="consultaId" type="int">
            <column name="CON_ID_CONSULTA">
                <comment></comment>
            </column>
        </property>
        <property name="identifServicio" type="string">
            <column name="SVP_IDENTIFICADOR_SERVICIO" length="15">
                <comment></comment>
            </column>
        </property>
        <property name="nombreServicio" type="string">
            <column name="SVP_NOMBRE_SERVICIO" length="100">
                <comment></comment>
            </column>
        </property>
       
         <many-to-one name="consulta" column="id" not-null="true"/>
       
   </class>                 
</hibernate-mapping>


SvcPostuladosHibernate .java

Code:
public class SvcPostuladosHibernate {
   static org.apache.log4j.Logger m_logger = org.apache.log4j.Logger.getLogger("com.test.portlet.contactos.model.ConsultaHibernate");

   private short id = (short) 0L;
   
   private short consultaId;
   private String identifServicio = null;
   private String nombreServicio = null;
   private short consulta;

   
   public short getId() {
      return id;
   }
   public void setId(short id) {
      this.id = id;
   }
   public short getConsultaId() {
      return consultaId;
   }
   public void setConsultaId(short consultaId) {
      this.consultaId = consultaId;
   }
   public String getIdentifServicio() {
      return identifServicio;
   }
   public void setIdentifServicio(String identifServicio) {
      this.identifServicio = identifServicio;
   }

   public String getNombreServicio() {
      return nombreServicio;
   }
   public void setNombreServicio(String nombreServicio) {
      this.nombreServicio = nombreServicio;
   }

   public short getConsulta() {
      return consulta;
   }
   public void setConsulta(short consulta) {
      this.consulta = consulta;
   }

   
   @Override
   public void Fill(HashMap params) {
      // TODO Auto-generated method stub

   }

   @Override
   public String getKey() {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public String getName() {
      // TODO Auto-generated method stub
      return null;
   }


   
}


Any Suggestions? Cause I can`t see the problem.

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.