• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Inheritance in Entity bean

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a query regarding the entity bean.
I am developing an application in which I am representing the "Card" as an entity bean. Since a card can be fall into different types like "Credit Card", "Debit Card" and etc..
Debit, credit or other card will have some common featutes like card expiry date, card issued by, and others.
So I will be mainitaining it in "Card" entity bean.
The features specific to individual card like Credit Card will have Credit Limit, whereas debit card won't have such feature.
So feature specific to individual card will be maintained at specfic entity bean like "DebitCard", "CreditCard"..
Whether it's right way of doing it? Whether I can able to use inheritance in entity beans? How to have the relationship with "Card" and "DebitCard", "CreditCard"?
Please throw some light on it.
 
Marshal
Posts: 7402
1423
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, you can have inheritance on entities. If you are using EJB 3.0, and if you do NOT need to map the super class (i.e. Card class) directly to the database, you could annotate the Card class as a MappedSuperClass and other sub classes (i.e. CreditCard, DebitCard can be exposed as entities to the database by using the @Entity annotation. In this case the Card class is used to provide the common information for sub classes.

And if you really need to map the super class too (i.e. Card class itself), there are some mapping strategies you can use. But I think the MappedSuperClass is what you really needed here.

Devaka.
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your prompt reply. Unfortunately, I am using old EJB 2.1.
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any suggestions on how to implement it in EJB2.1?
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help to give some suggestion on it.
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still having hope on this forum..any advice/help?
 
reply
    Bookmark Topic Watch Topic
  • New Topic