Inserting data using a JPA entity
You can use access beans to insert new data, as part of your business logic, for default JPA entities.
To create new data with JPA, define a customized JPA DAO implementation that extends the
AbstractJpaEntityDaoImpl
to insert data.
The following code example creates a new JPA
entity:
EntityDao socialAccountDao = new SocialAccountDaoImpl();
SocialAccount socialAccount = new SocialAccount();
socialAccount.setFacebookId(facebookId);
socialAccount.setName(facebookName);
socialAccount.setMemberId(userId);
socialAccount.setStoreId(Integer.valueOf(1));
socialAccount.setSocialAccountId(socialAccountDao.generatePrimaryKey("xsocialaccount"));
socialAccountDao.persist(socialAccount);