• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate Mapping Many-to-One using Annotations Issue  RSS feed

Paranidharan Selvaraj
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"

I am using AnnotationSessionFactoryBean.. Shown below is my context file.
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean">
<property name="configLocation">
<property name="annotatedClasses">

I was successfully annotating MyClass. Class A is having many-to-one association with Class B. Now i try to annotate class B and class A will have hbm mapping. I am not able to do it.
When deploying i get the error message as below:::

Caused by: org.hibernate.MappingException: An association from the table my_table1 refers to an unmapped class: pack.ClassB
at org.hibernate.cfg.Configuration.secondPassCompileF oreignKeys(Configuration.java:1258)
at org.hibernate.cfg.Configuration.secondPassCompile( Configuration.java:1176)
at org.hibernate.cfg.AnnotationConfiguration.secondPa ssCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Conf iguration.java:1121)
at org.springframework.orm.hibernate3.LocalSessionFac toryBean.buildSessionFactory(LocalSessionFactoryBe an.java:674)
at org.springframework.orm.hibernate3.AbstractSession FactoryBean.afterPropertiesSet(AbstractSessionFact oryBean.java:211)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1288)

Is it possible to annotate class B alone without annotating Class A?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!