• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Mapping Exception

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to do a many-to-many association using hibernate. I am having an
EVENT table and PERSON table. I am trying to get many-to-many association between these two tables using a junction table PERSON_EVENT. Following is the
mapping xml


Now when i tried to run the program i am getting the following exception
org.hibernate.MappingException: An association from the table PERSON_EVENTS refers to an unmapped class: EVENT

Can anyone suggest me how to solve this.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably don't have your EVENT mapping listed in your configuration. If you are using hibernate.cfg.xml have you included the event mapping?
 
kranthi chamarthi
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah i included the Event mapping in my hibernate.cfg.xml
Follwing is the configuration xml

and following is the event hbm xml
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You included a mapped resource called "Event". Your mapping from Person is to a mapped resource called EVENT.

Remember, Java is case-sensitive.
 
kranthi chamarthi
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right Paul...Thank you very much.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:You included a mapped resource called "Event". Your mapping from Person is to a mapped resource called EVENT.

Remember, Java is case-sensitive.


Hi Paul,
I am having the same problem and after reading your reply tried to solve it but comes up with the error:
n association from the table PERSON_EVENT refers to an unmapped class: Event



<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">bhuru</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<!-- Mapping files -->
<mapping resource="Event.hbm.xml"/>
<mapping resource="Person.hbm.xml"/>


</session-factory>
</hibernate-configuration>

Person.hbm.xml
------------------
<hibernate-mapping>
<class name="Person" table="PERSON">

<id name="id" column="PERSON_ID">
<generator class="native"/>
</id>

<property name="firstName"/>

<set name="events" table="PERSON_EVENT">
<key column="PERSON_ID"/>
<many-to-many column="EVENT_ID" class="Event"/>
</set>

</class>
</hibernate-mapping>

Event.hbm.xml
------------------

<hibernate-mapping>


<class name="hibernate.Event" table="EVENT">

<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>

<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>





</class>


</hibernate-mapping>



I would genuinely appreciate any help.
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic