I'm trying to setup a model that separates from-the-database-generated code from user editable code, in order to minimize coding efforts. In order to do so, each entry has two classes, where one inherits the other.
The generated class is being inherited, e.g.:
@MappedSuperclass
public class Article
...
While the editable class only refers to the table:
@Entity
@Table(name="article")
public class Article extends nl.reinders.bm.generated.Article
...
Now, declaring a ManyToOne gives no problems, e.g:
@ManyToOne @JoinColumn(name="articlenr")
private nl.reinders.bm.Article iArticle;
However, trying to reverse this does not work:
@OneToMany(mappedBy = "iArticlenr")
public java.util.Collection<nl.reinders.bm.Articlealias> iArticlealiases;
This gives a "mappedBy reference an unknown target entity property: nl.reinders.bm.Articlealias.iArticlenr in nl.reinders.bm.Article.iArticlealias"
This is correct, since the property is not defined in nl.reinders.bm.Articlealias, but in the superclass (as explained in the beginning of this post), being:
nl.reinders.bm.generated.Articlealias.iArticlenr
Can I tell mappedBy what class to look in?
Hibernate version:
3.2.3ga
Mapping documents:
JPA
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: nl.reinders.bm.Article2Articlecat.iArticlenr in nl.reinders.bm.Article.iArticle2ArticlecatsWhereIAmArticle
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:247)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at nl.reinders.BMTest.main(BMTest.java:36)
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: nl.reinders.bm.Article2Articlecat.iArticlenr in nl.reinders.bm.Article.iArticle2ArticlecatsWhereIAmArticle
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:506)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:471)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:178)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:235)
... 3 more
Name and version of the database you are using:
Informix 10
The generated SQL (show_sql=true):
N/A
|