Tutorials > Content management > Create a content-managed resource > Creating the new resource
Create new ejbCreate and ejbPostCreate methods
The ejbCreate() method is used to insert a row into the database table and must be added to the ExtendedCatalogDescriptionBean.
Procedure
- In the Java EE Hierarchy view, expand WebSphereCommerceServerExtensionsData.
- Expand Deployment Descriptor: WebSphereCommerceServerExtensionsData > Entity Beans > ExtendedCatalogDescription, and open the ExtendedCatalogDescriptionBean class.
- Create a new ejbCreate(EntityBeanCreationData data) method, by adding the following code into the class:
public com.mycompany.catalog.objects.ExtendedCatalogDescriptionKey ejbCreate(EntityBeanCreationData data) throws javax.ejb.CreateException { _initLinks(); ExtendedCatalogDescriptionEntityBeanCreationData extendedCatalogData = (ExtendedCatalogDescriptionEntityBeanCreationData) data; setCatalog_id(extendedCatalogData.getCatalog_id()); setLanguage_id(extendedCatalogData.getLanguage_id()); setLastModified(extendedCatalogData.getLastModified()); setFrontImg(extendedCatalogData.getFrontImg()); setBackImg(extendedCatalogData.getBackImg()); setSideImg(extendedCatalogData.getSideImg()); setTopImg(extendedCatalogData.getTopImg()); return null; }
- Press Ctrl+Shift+O to organize imports. The class EntityBeanCreationData should now be found.
- Save the code changes. The following warning might be displayed in the Ttask view: This class should implement a matching ejbPostCreate method for this method. You create the ejbPostCreate method later in this tutorial.
- You must add the new ejbCreate(EntityBeanCreationData data ) method to the home interface. This makes the method available in the generated access bean. In the Outline view, right-click the ejbCreate(EntityBeanCreationData data) method and select Enterprise Bean > Promote to Home Interface. Next we will create a new ejbPostCreate(EntityBeanCreationData data) method so that it has the same parameters as the ejbCreate(EntityBeanCreationData data) method. Every ejbCreate(arg1, arg2…) method must have a corresponding ejbPostCreate(arg1, arg2…) method according to the EJB specification requirements. Create a new ejbPostCreate(EntityBeanCreationData data) method so that it has the same parameters as the ejbCreate(EntityBeanCreationData data) method:
- In the ExtendedCatalogDescriptionBean class, create a new ejbPostCreate(EntityBeanCreationData data) method, by adding the following code into the class:
public void ejbPostCreate (EntityBeanCreationData data) throws javax.ejb.CreateException {}
- Press Ctrl+Shift+O to organize imports. The class EntityBeanCreationData should now be found.
- Save the code changes. The warning about a missing matching ejbPostCreate method is resolved.