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
-
In your development environment, Write code to access XSOCIALACCOUNT data with JPA.
-
Create a JPA entity for XSOCIALACCOUNT data.
- Create JPA entity class SocialAccount with package com.ibm.commerce.sample.objects.
- Refer to the sample code to complete the class.
-
Create code to insert, update and delete data.
- Create JPA DAO implementation class SocialAccountDaoImpl, which extends
AbstractJPAEntityDaoImpl<SocialAccount, Long> with package
com.ibm.commerce.sample.persistence.
- Refer to the sample code to complete the class.
-
(Optional) Implement access control for the entity.
- Create the JPA entity class SocialAccountAccessHelper, which extends AccessHelper with
package com.ibm.commerce.sample.objsrc.
- Refer to the sample code to complete the class.
-
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.
-
Create a post-process command, and implementation for a user registration REST API.
- create the post-process command interface CreateSocialAccountCmd, which extends the
ControllerCommand. Refer to the sample code to complete the class.
- Create the post-process command interface CreateSocialAccountCmdImpl, which extends the
ControllerCommandImpl and implements CreateSocialAccountCmd. Refer to the sample code to complete
the class.
-
Create a post-process command and implementation for a user information REST API.
- Create post-process command interface GetSocialAccountCmd which extends ControllerCommand. Refer
to the sample code to complete the class.
- create the post-process command interface GetSocialAccountCmdImpl, which extends
ControllerCommandImpl and implements GetSocialAccountCmdCmd. Refer to the sample code to complete
the class.