Alex Rivera | Logout

Hibernate association references unmapped class exception

Asked 2011-11-27T19:21:24.727
8

I have the following class:

public class Car implements Comparable<Car>{

private long idCar;

private String model;

private String immat; //Car License Plate

private Company company;

private Manufacturer manufacturer;    

private Calendar registrationDate;

private Calendar lastControlDate;

//Has empty constructor + Getters and setters here onwards...

and it's hibernate configuration file:

<?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>
  <class name="Car" table="cars" lazy="true"> 
    <id name="idCar" type="long" column="idCar">
      <generator class="native" />
    </id>

    <property name="model" type="string" column="model" />
    <property name="immat" type="string" column="immat" />
    <property name="registrationDate" type="date" column="registrationDate" />
    <property name="lastControlDate" type="date" column="lastControlDate" />

    <many-to-one name="company" class="fr.model.company.Company" column="idCompany"
     not-null="true" />
    <many-to-one name="manufacturer" class="fr.model.component.Manufacturer"
             column="idManufacturer" not-null="true" />    

  </class>
</hibernate-mapping>

and the Manufacturer class:

public class Manufacturer implements Comparable<Manufacturer> {

private Long idManufacturer;
private String name;

I keep getting the association unmapped references error but I can't figure out why so far.

Edit: Manufacturer mapping -

    <?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">
<hib
Edit
Report

1 Answer

15

Initial SessionFactory creation failed.org.hibernate.MappingException: Association references unmapped class: fr.synapture.model.company.Car

This suggests that you've mapped a class which the session factory doesn't know about. You need to include Car in the Session Factory configuration.

To confirm this please could you include the Hibernate configuration in your questions.

answered 2011-11-27T21:13:14.723

Your Answer