Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problem adding more entity classes
Problem adding more entity classes [message #1369599] Tue, 20 May 2014 17:09 Go to next message
Kathrin Kahlhoefer is currently offline Kathrin KahlhoeferFriend
Messages: 2
Registered: May 2014
Junior Member
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 #1369930 is a reply to message #1369599] Tue, 20 May 2014 20:11 Go to previous messageGo to next message
Randy Tidd is currently offline Randy TiddFriend
Messages: 8
Registered: August 2013
Junior Member
What do you mean by "parent entity"? Can you post the source code for class B? Also posting the entire stack trace (or at least the portion that includes EclipseLink code) for the NullPointerException may help.
Re: Problem adding more entity classes [message #1372158 is a reply to message #1369599] Wed, 21 May 2014 18:09 Go to previous message
Kathrin Kahlhoefer is currently offline Kathrin KahlhoeferFriend
Messages: 2
Registered: May 2014
Junior Member
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

}
Previous Topic:Problem persisting without cascade
Next Topic:wrong xsd is generated for subclass
Goto Forum:
  


Current Time: Sun May 24 05:39:49 GMT 2015

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

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