This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • 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(
at org.hibernate.cfg.Configuration.secondPassCompile(
at org.hibernate.cfg.AnnotationConfiguration.secondPa ssCompile(
at org.hibernate.cfg.Configuration.buildMappings(Conf
at org.springframework.orm.hibernate3.LocalSessionFac toryBean.buildSessionFactory(LocalSessionFactoryBe
at org.springframework.orm.hibernate3.AbstractSession FactoryBean.afterPropertiesSet(AbstractSessionFact
at AutowireCapableBeanFactory.invokeInitMethods(Abstr

Is it possible to annotate class B alone without annotating Class A?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!