• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Non-Entity Classes in the Entity Inheritance Hierarchy

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Explanation from Spec

The non-entity superclass serves for inheritance of behavior only. The state of a non-entity
superclass is NOT PERSISTENT. Any state inherited from non-entity superclasses is nonpersistent
in an inheriting entity class.


My quesion : If we are not able to save state inherited from Non-Entity superlass is Non-Persistent in an inherting entity class. Then what is use of this design?
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you also check the example given in the spec.

You can think these classes as some helper classes which might be used to provide some logic not related to your persistance context. Maybe something like validation of incrementing a counter variable as shown in the spec example.

Let's say you might already have logic sitting in a jar file. How would you use it in an entity? Non-entity classes would help you to use such "behavior" logic in your entity classes.
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at the @MappedSuperclass annotation.

In short, if you annotate your superclass with the @mappedSuperclass annotation, then any entity subclass inherits the persistance properties of the base class.
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic