Reputation: 107
I apologize if this question has been posted before, or if the information is readily available and I'm just a fool for not finding it. I have looked quite a bit. I know they cannot be private because eclipselink uses reflection to instantiate the classes.
I seem to find that when I mark classes as private, all fails. However, if I mark them protected, LAZY loading will fail, while EAGER works fine. Is that an established rule somewhere in documentation, or does it just work sometimes?
In other words, must eclipselink jpa entity classes be public? I'm using a derby embedded database as my underlying database if it matters.
Upvotes: 0
Views: 562
Reputation: 9586
From http://www.objectdb.com/java/jpa/entity/types
Entity Class Requirements
A portable JPA entity class:
- should be a top-level class (i.e. not a nested / inner class).
- should have a public or protected no-arg constructor.
- cannot be final and cannot have final methods or final instance variables.
Since the visibility modifier for top level classes can either be public
or package level if unspecified, the answer is the entity has to be a top level class which is public
or has package level visibility.
Upvotes: 4