-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: OneToMany in combination with MappedSuperclass
PostPosted: Tue Apr 10, 2007 10:59 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 9:41 am
Posts: 23
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 3:19 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 9:41 am
Posts: 23
Hmmmm. Can I, based on the lack of replies, assume that the problem is outside anyone's domain of interest? Let's see what JPOX makes of it... (The advantage of using JPA.)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 8:34 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 9:41 am
Posts: 23
For those interested: I stumbled across the Oracle Toplink JPA implementation before JPOX and hooked that up. Aside from having to fix some minor issues and some differences in the JPQL, it works perfectly.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 24, 2007 4:25 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 9:41 am
Posts: 23
And for those still interested: Toplink has some weaving problems, so the lazy loading is not working, for the rest it is.

OpenJPA also refuses to process the "@Entity extends @MappedSuperclass". I didn't get around to JPOX, still hoping Toplink's weaving will get worked out.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.