Hibernate关联引用了未映射的类异常

我有以下课程:

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...

它是hibernate配置文件:

<?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>

和制造商类:

public class Manufacturer implements Comparable<Manufacturer> {

private Long idManufacturer;
private String name;

我一直得到关联未映射的引用错误,但我无法弄清楚为什么到目前为止.

编辑:制造商映射 –

    <?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="Manufacturer" table="manufacturer">
      <id name="idManufacturer" type="long" column="idManufacturer">
            <generator class="native" />
    </id>

    <property name="name" type="string" not-null="true" />

  </class>

</hibernate-mapping>

例外:

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

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

这表明您已经映射了会话工厂不了解的类.您需要在会话工厂配置中包含Car.

要确认这一点,请在问题中包含Hibernate配置.

翻译自:https://stackoverflow.com/questions/8288300/hibernate-association-references-unmapped-class-exception

转载注明原文:Hibernate关联引用了未映射的类异常