Buscar este blog

viernes, 29 de junio de 2012

Hibernate: error many-to-many

[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: An association from the table TRACK_ARTISTS does not specify the referenced entity


BUILD FAILED
/media/SWAP/ProyectoH/build.xml:67: org.hibernate.MappingException: An association from the table TRACK_ARTISTS does not specify the referenced entity
    at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1241)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)

 Este error es causado porque el nombre de la clase esta mal. En el achirvo aparece Artist y debería se com.oreilly.hh.

 
<?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="Artist">
    <meta attribute="class-description">
        Represent a artist who is associed with a track or album.
        @autor Victor Aguilar
    </meta>
    
    <id name="Id" type="int" column="ARTIST_ID">
        <meta attribute="scope-set">protected</meta>
        <generator class="native"/>
    </id>
    
    <property name="name" type="string" column="NAME">
        <meta attribute="use-in-tostring">true</meta>
    </property>
    
    <set name="track" table="TRACK_ARTISTS" inverse="true">
        <key column="ARTIST_ID"/>
        <many-to-many entity-name="com.oreilly.hh.Track" column="TRACK_ID"/>
    </set>
</class>


  

</hibernate-mapping>

No hay comentarios:

Publicar un comentario