Problem adding more entity classes [message #1369599] |
Tue, 20 May 2014 13:09  |
Eclipse User |
|
|
|
Hi,
I'm migrating an application to JPA/Eclipselink. I've been implementing more and more entity classes and everything went fine. Recently, adding another entity class leads to problems with other entities.
Let's call this new entity class A. At the beginning of the application I load a couple of objects of class B which have a reference to their parent entity (also of class B). That reference is never null in the database, however with the newly added entity class a NullPointerException is thrown when I try to access the parent entity field. Class A has no connection at all to class B.
When I remove an older entity class C, everything works fine, with B as well as A.
I tried that with different entity classes and the result is always the same. When I get over a certain number of entity classes, I get NullPointerExceptions in places where the code worked fine before. The NullPointerException is the only exception I get.
I've got 96 entity classes (and 12 mapped superclasses, if they count too). The 97th class causes the problem.
I'm using version 2.5.2. I tried using 2.6.0 and 2.5.1 instead, but that didn't help.
I can't be the only one with so many classes. Is there a solution to this?
|
|
|
|
Re: Problem adding more entity classes [message #1372158 is a reply to message #1369599] |
Wed, 21 May 2014 14:09  |
Eclipse User |
|
|
|
I found the issue today and it works now, though I still don't understand why it only occured with 97+ entities.
The field that was null was declared in the abstract super class, with a generic return type. I moved the field into the subclasses, which makes it redundant. Can anybody tell me if there's a way to keep it in the abstract class?
Class B and its superclass, how they used to be:
@MappedSuperclass
public abstract class AbstractB<T extends AbstractB> {
@Id
private int id;
@ManyToOne
private T parentEntity;
//...constructor, getters, setters
}
@Entity
public class B extends AbstractB<B> {
//some other fields
}
Class B and its superclass how they are now:
@MappedSuperclass
public abstract class AbstractB {
@Id
private int id;
//...constructor, getters, setters
}
@Entity
public class B extends AbstractB {
@ManyToOne
private B parentEntity;
//some other fields
}
|
|
|
Powered by
FUDForum. Page generated in 0.04640 seconds