Updating data using an JPA entity

You can update default JPA entities in your business logic by using an access bean. If you have customized JPA entities, you do not need to wrap them in an access bean. Instead, define a JPA DAO implementation that extends AbstractJPAEntityDaoImpl.

About this task

When you update data in your business logic, you will first be finding data using a JPA entity. Then you can alter the settings on the class to change data. Any changes you make will persist when the transaction commits.

The following example shows how to retrieve, update, and commit data for a new created JPA entity.

Procedure

  1. Find a JPA entity.
    EntityDao socialAccountDao = new SocialAccountDaoImpl();
            SocialAccount socialAccount=socialAccountDao.find(new Long(10001));
  2. Update the name.
    
    socialAccount.setName("test");