Create JPA code to read and write Facebook information

In this lesson, you write JPA code to access the new database XSOCIALACCOUNT table, and to read from and write to the table.

Before you begin

Please refer to WebSphereCommerceServerExtensionsData folder for the sample code that is required to complete the tutorial.

Procedure

  1. In your development environment, Write code to access XSOCIALACCOUNT data with JPA.
    1. Create a JPA entity for XSOCIALACCOUNT data.
      1. Create JPA entity class SocialAccount with package com.ibm.commerce.sample.objects.
      2. Refer to the sample code to complete the class.
    2. Create code to insert, update and delete data.
      1. Create JPA DAO implementation class SocialAccountDaoImpl, which extends AbstractJPAEntityDaoImpl<SocialAccount, Long> with package com.ibm.commerce.sample.persistence.
      2. Refer to the sample code to complete the class.
    3. (Optional) Implement access control for the entity.
      1. Create the JPA entity class SocialAccountAccessHelper, which extends AccessHelper with package com.ibm.commerce.sample.objsrc.
      2. Refer to the sample code to complete the class.
  2. Write code to read/write XSOCIALACCOUNT with a REST framework enhancement. This enhancement will enable you to write custom data after the default user registration REST API invocation, and can be retrieved after the default user information is retrieved via the REST API.
    1. Create a post-process command, and implementation for a user registration REST API.
      1. create the post-process command interface CreateSocialAccountCmd, which extends the ControllerCommand. Refer to the sample code to complete the class.
      2. Create the post-process command interface CreateSocialAccountCmdImpl, which extends the ControllerCommandImpl and implements CreateSocialAccountCmd. Refer to the sample code to complete the class.
    2. Create a post-process command and implementation for a user information REST API.
      1. Create post-process command interface GetSocialAccountCmd which extends ControllerCommand. Refer to the sample code to complete the class.
      2. create the post-process command interface GetSocialAccountCmdImpl, which extends ControllerCommandImpl and implements GetSocialAccountCmdCmd. Refer to the sample code to complete the class.