Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • 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.
    Code Block
    SQL
    SQL
    borderStylesolid
    titleACCOUNT 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))
    
    The contents of ACCOUNT table in the AccountDB database are as follows
  • The following data will be inserted into ACCOUNT table.
    No Format
    borderStylesolid
    titleACCOUNT 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!!
    

Note that JPA has inserted the value CURRENTACCOUNT in the column ACCOUNTTYPE for CurrentAccount entities and inserted the value {SAVINGSACCOUNT}} for SavingsAccount entites.