Hibernate association refers to exception of an excluded class

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 sleeping 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 manufacturer class:

 public class Manufacturer implements Comparable<Manufacturer> { private Long idManufacturer; private String name; 

I get an unmapped reference error message, 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"> <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> 

An exception:

 Initial SessionFactory creation failed.org.hibernate.MappingException: Association references unmapped class: fr.synapture.model.company.Car 
+6
source share
4 answers

Initial creation of SessionFactory failed.org.hibernate.MappingException: Association link does not extend class: fr.synapture.model.company.Car

This suggests that you have mapped a class that the factory session does not know about. You need to include Car in the factory session configuration.

To confirm this, can you include the Hibernate configuration in your questions.

+11
source

In my application, I have an nHibernate mapping project, separate with a logical project (2 projects). I set all the mappings to the "model project" and ... I have this error: the association refers to an unmarked class:

In my sytuation, I had to set the properties of MyClass.hbm.xml to "Build Action - Enabled Resource".

+3
source

Manufacturer must also display the class, and therefore must Company , as both are referenced from Car mapping.

+1
source

Just include xmls Manufacturer.hbm.xml and Car.hbm.xml in

 <mapping resource="Manufacturer.hbm.xml"/> <mapping resource="Car.hbm.xml"/> 

in hibernate.cfg.xml

0
source

Source: https://habr.com/ru/post/902499/


All Articles