Hibernate Mapping Many-to-One using Annotations Issue
I have a many to one relationship between 2 classes A and B(a->B). I want to use annotations unfortunately there are many classes to be converted in my project( hibernate + spring integrated ). I ended up changing only Class B to annotations and class A will have the old hbm mapping file itself..
While doing so i get an exception creating sessionFactory "An association from the table A refers to an unmapped class: B"
Is it not possible to use annotation and hbm configuration mixed?
One to many using Hibernate .
If you want to make the one-to-many / Manay-to-one relation between two tables, You have to define two classes for each Enity. As you mentioned . Both class A and B should be Annotation class. You can not use HBM for one and Annotation for other class if you want to make relation between those classes,
Because in class A you have to mention the targetEntity which is nothing but the other class.
You can refer this site for getting idea on this,
http://j2eereference.com/2011/01/one...ing-hibernate/