Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Contradiction in the JPA Specs

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I'm finding the following terms form the JPA Specs to contradict.

2.1 Requirements on the Entity Class
The entity class must be annotated with the Entity annotation or denoted in the XML descriptor as an
entity.
The entity class must have a no-arg constructor. The entity class may have other constructors as well.
The no-arg constructor must be public or protected.
The entity class must be a top-level class. An enum or interface should not be designated as an entity.
The entity class must not be final. No methods or persistent instance variables of the entity class may be
final.
If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the
entity class must implement the Serializable interface.

Entities support inheritance, polymorphic associations, and polymorphic queries.
Both abstract and concrete classes can be entities. Entities may extend non-entity classes as well as
entity classes, and non-entity classes may extend entity classes.
The persistent state of an entity is represented by instance variables, which may correspond to Java-
Beans properties. An instance variable may be directly accessed only from within the methods of the
entity by the entity instance itself. Instance variables must not be accessed by clients of the entity. The
state of the entity is available to clients only through the entity’s accessor methods (getter/setter methods)
or other business methods. Instance variables must be private, protected, or package visibility.


They claim that an Entity must be a top level class and in the next page they say an Entity may extend a non-entity class? What is this here?
 
Sandeep Awasthi
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They claim that an Entity must be a top level class and in the next page they say an Entity may extend a non-entity class? What is this here?

I could not understand what you mean. Where is contradiction? Can't a top level class extend another class?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I understood it now. I did not read the line that followed...enum or interface....Thanks for pointing it out anyways!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic