THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Entities can exhibit inheritance relationship among themselves. The entities involved in inheritance relationship can be persisted/updated/retrieved independently. There are several ways of realizing inheritance relationship among entities. There are as follows.
- Single database table per class hierarchy
- Separate database table per subclass
- Single database table per concrete entity class
Single database table per class hierarchy
...
The persistence schema uses AccountDB
derby database. It declares the entities in the persistence unit as well. The following procedure explains how to deploy/run the sample.*
- Create an EAR application that contains an EJB application packaging all entity classes, ejb classes and META-INF/persistence.xml
...
- Create META-INF/ejb-jar.xml. Since we have used annotations, we do not have to provide any declarations in it.
...
- Create a WEB application in the EAR and add the above servlet.
...
- Create a derby database by name
AccountDB
using admin console.
...
- Create a table by name
ACCOUNT
as following.
The contents ofCode Block SQL SQL borderStyle solid title ACCOUNT table create table ACCOUNT(ACCOUNTNO integer, ACCOUNTTYPE varchar(50), NAME varchar(50), ADDRESS varchar(225), BRANCHCODE integer, INTERESTRATE decimal(15,2), MINBALANCE decimal(15,2), BALANCE decimal(15,2), CURRENTACCOUNTRULES varchar(225), SAVINGSACCOUNTRULES varchar(225))
ACCOUNT
table in theAccountDB
database are as follows.
Note that JPA has inserted the valueNo Format borderStyle solid title ACCOUNT table ACCOUNTNO ACCOUNTTYPE NAME ADDRESS BRANCHCODE INTERESTRATE MINBALANCE BALANCE CURRENTACCOUNTRULES SAVINGSACCOUNTRULES 1 CURRENTACCOUNT Joe Joe's address 10 20.00 200.00 5000.00 Current Account!! 2 SAVINGSACCOUNT Joe Joe's address 12 234.00 4534.00 13323.00 Savings Account!! 3 CURRENTACCOUNT John John's address 10 20.00 200.00 5000.00 Current Account!! 4 SAVINGSACCOUNT John John's address 12 234.00 4534.00 13323.00 Savings Account!!
CURRENTACCOUNT
in the columnACCOUNTTYPE
for CurrentAccount entities and inserted the value {SAVINGSACCOUNT}} for SavingsAccount entites.