javahibernatehibernate-tools

org.hibernate.MappingException: An association from the table X refers to an unmapped class


I'm having a problem with the generation of entities from hibernate tools.

I am trying to generate the entities of 4 tables, pru1 and pru2 have a relationship many to many in the association table pru3. The pru3 keys pass as foreign keys to the pru4 table.

  pru1 ---> pru3 <---- pru2
              |
              |
              V 
            pru4

If I am not mistaken, the entity pru1 should have a list of pru2, pru2 a list of pru1 and pru4 an object of pru1 and another of pru2.

When I run hibernate tools, I get rid of this error:

org.hibernate.MappingException: An association from the table PRU4 refers to an unmapped class: com.entities.Pru3 An association from the table PRU4 refers to an unmapped class: com.entities.Pru3 org.hibernate.MappingException: An association from the table PRU4 refers to an unmapped class: com.entities.Pru3 An association from the table PRU4 refers to an unmapped class: com.entities.Pru3

In the configuration of hibernate tools I checked all options, including detect many to many tables

Is it possible to do this type of mapping with hibernate tools?

Thanks in advance


Solution

  • I've solved my problem in a very inelegant way.

    Having a relationship that comes from a table that solves an N:N cardinality, it is necessary to create this entity.

    I could have unchecked the "Detect many-to-many tables" option, but I have other N:N relationship tables, and these I didn't want to be generated.

    The solution I chose was to create an additional field in my PRU3 table, to force hibernate tools to generate the entity.

    Later I have erased the field in the BBDD and in the entity.

    I'm sure that this type of mapping could be done automatically playing with the reveng.xml or implementing a strategy, but it was going to take me much more time than I have.