Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.AnnotationException: mappedBy reference an unknown target entity property

 
peter kosmas
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ...
I have a problem by mapping these two tables

i want the keys that are mapped not to be generated...
but to be entered manually ..
I am new to JPA and trying some examples ...
Can someone help ???

Create a row with isbn xx
and insert by that isbn 1-2-3 Instances with data by that isbn
the problem is i get the exception :
Exception in thread "main" org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: jpa.beans.BookInfo.bookInfo in jpa.beans.Book.bookInfo
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:576)







So i use this example and get









import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import jpa.beans.Book;
import jpa.beans.BookInfo;
import org.hibernate.SessionFactory;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.classic.Session;

import org.hibernate.tool.hbm2ddl.SchemaExport;


 
Shannon McGee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,

I would start by removing the "mappedBy" annotation from the getBookInfo method. You shouldn't need any additional annotations for this relationship

This annotation is typically used to map the reverse side of a relationship that has already been captured in another class.

A side note: you may find that it's easier to put the attribute annotations above each attribute declaration. I didn't see anything in your code that would necessitate using the annotations at the method level.

-Shannon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic