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.xmlCode:
<?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.xmlCode:
<?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.javaCode:
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.xmlCode:
<?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 .javaCode:
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