Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Reference to Superclass
icon5.gif  Reference to Superclass [message #830332] Tue, 27 March 2012 13:46 Go to next message
A.Rothe  is currently offline A.Rothe Friend
Messages: 12
Registered: November 2011
Location: Leipzig, Germany
Junior Member

I have an abstract superclass, which is the superclass of every entity:

public abstract class AbstractEntity
implements Serializable {

// ...

@Table(name = "BLUBB")
public class Blubb extends AbstractEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({ @JoinColumn(name = "THING", referencedColumnName = "ID") })
private AbstractEntity thing;
// ....

JPA returns an error, that I can not use AbstractEntity there. But I don't know, which type of entity is returned at this point. I have stored the type in another entity, here I need a reference to the specific instance. But actually the only thing I need is the ID of the instance.

How I can prevent that error?

Exception Description: [class Blubb] uses a non-entity [class AbstractEntity] as target entity in the relationship attribute [field instance]..

Thanks a lot
Re: Reference to Superclass [message #831209 is a reply to message #830332] Wed, 28 March 2012 16:04 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1342
Registered: July 2009
Senior Member
Hello Andre,

Can you explain the relationship a bit or what you are trying to accomplish? It isn't clear why you would want to have Blubb with a 1:1 that can hold any instance, or how you would expect to represent this in the database. When you read in a Blubb, it needs to use that mapping to read in a thing instance, so the type needs to be determined somehow.

If the type is determined somewhere else (I assume you mean other entities are extending Blubb), why not map the 'thing' at those points?

Previous Topic:How to restrict other queries getting executed.
Next Topic:How to compile eclipselink codebase
Goto Forum:

Current Time: Tue Mar 31 08:32:43 GMT 2020

Powered by FUDForum. Page generated in 0.02323 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top