Entity EJB


Overview


Remote Interface

 package edu.unc.cs.jbs.address.beans;

/**
 * This is an Enterprise Java Bean Remote Interface
 */
public interface Address extends javax.ejb.EJBObject {

/**
 * Getter method for address
 * @return java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */

java.lang.String getAddress() throws java.rmi.RemoteException;

/**
 * Getter method for city
 * @return java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
java.lang.String getCity() throws java.rmi.RemoteException;
/**
 * 
 * @return java.lang.String
 * @exception String The exception description.
 */
java.lang.String getName_first() throws java.rmi.RemoteException;
/**
 * 
 * @return java.lang.String
 * @exception String The exception description.
 */
java.lang.String getName_last() throws java.rmi.RemoteException;
/**
 * Getter method for name_middle
 * @return java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
java.lang.String getName_middle() throws java.rmi.RemoteException;
/**
 * Getter method for state
 * @return java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
java.lang.String getState() throws java.rmi.RemoteException;
/**
 * Getter method for zip
 * @return java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
java.lang.String getZip() throws java.rmi.RemoteException;
/**
 * Setter method for address
 * @param newValue java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */

void setAddress(java.lang.String newValue) throws java.rmi.RemoteException;

/**
 * Setter method for city
 * @param newValue java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
void setCity(java.lang.String newValue) throws java.rmi.RemoteException;
/**
 * 
 * @return void
 * @param newValue java.lang.String
 * @exception String The exception description.
 */
void setName_first(java.lang.String newValue) throws java.rmi.RemoteException;
/**
 * 
 * @return void
 * @param newValue java.lang.String
 * @exception String The exception description.
 */
void setName_last(java.lang.String newValue) throws java.rmi.RemoteException;
/**
 * Setter method for name_middle
 * @param newValue java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
void setName_middle(java.lang.String newValue) throws java.rmi.RemoteException;
/**
 * Setter method for state
 * @param newValue java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
void setState(java.lang.String newValue) throws java.rmi.RemoteException;
/**
 * Setter method for zip
 * @param newValue java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
void setZip(java.lang.String newValue) throws java.rmi.RemoteException;
}

Home Interface

package edu.unc.cs.jbs.address.beans;

/**
 * This is a Home interface for the Entity Bean
 */

public interface AddressHome extends javax.ejb.EJBHome {

/**
 * create method for a CMP entity bean
 * @return edu.unc.cs.jbs.address.beans.Address
 * @param argName_first java.lang.String
 * @param argName_last java.lang.String
 * @exception javax.ejb.CreateException The exception description.
 * @exception java.rmi.RemoteException The exception description.
 */

edu.unc.cs.jbs.address.beans.Address create(java.lang.String argName_first, java.lang.String argName_last) throws javax.ejb.CreateException, java.rmi.RemoteException;

/**
 * findByPrimaryKey method comment
 * @return edu.unc.cs.jbs.address.beans.Address
 * @param key edu.unc.cs.jbs.address.beans.AddressKey
 * @exception java.rmi.RemoteException The exception description.
 * @exception javax.ejb.FinderException The exception description.
 */

edu.unc.cs.jbs.address.beans.Address findByPrimaryKey(edu.unc.cs.jbs.address.beans.AddressKey key) throws java.rmi.RemoteException, javax.ejb.FinderException;

}

Key

package edu.unc.cs.jbs.address.beans;

public class AddressKey implements java.io.Serializable {

	public java.lang.String name_first;
	public java.lang.String name_last;
	private final static long serialVersionUID = 3206093459760846163L;

/**
 * Default constructor
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */

public AddressKey() {
	super();
}

/**
 * Initialize a key from the passed values
 * @param argName_first java.lang.String
 * @param argName_last java.lang.String
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */

public AddressKey(java.lang.String argName_first, java.lang.String argName_last) {
	name_first = argName_first;
	name_last = argName_last;
}

/**
 * equals method
 * @return boolean
 * @param o java.lang.Object
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public boolean equals(Object o) {
	if (o instanceof AddressKey) {
		AddressKey otherKey = (AddressKey) o;
		return ((this.name_first.equals(otherKey.name_first)
		 && this.name_last.equals(otherKey.name_last)));
	}
	else
		return false;
}
/**
 * hashCode method
 * @return int
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public int hashCode() {
	return (name_first.hashCode()
		 + name_last.hashCode());
}
}

Entity Bean

package edu.unc.cs.jbs.address.beans;

import java.rmi.RemoteException;
import java.security.Identity;
import java.util.Properties;
import javax.ejb.*;

/**
 * This is an Entity Bean class with CMP fields
 */

public class AddressBean implements EntityBean {
	public String address;
	public String city;
	private javax.ejb.EntityContext entityContext = null;
	public String name_first;
	public String name_last;
	public String name_middle;
	private final static long serialVersionUID = 3206093459760846163L;
	public String state;
	public String zip;

/**
 * This method was generated for supporting the associations.
 * @return java.util.Vector
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
protected java.util.Vector _getLinks() {
	java.util.Vector links = new java.util.Vector();
	return links;
}
/**
 * This method was generated for supporting the associations.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
protected void _initLinks() {}
/**
 * This method was generated for supporting the associations.
 * @exception java.rmi.RemoteException The exception description.
 * @exception javax.ejb.RemoveException The exception description.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
protected void _removeLinks() throws java.rmi.RemoteException, javax.ejb.RemoveException {
	java.util.Enumeration links = _getLinks().elements();
	while (links.hasMoreElements()) {
		try {
			((com.ibm.ivj.ejb.associations.interfaces.Link) (links.nextElement())).remove();
		}
		catch (javax.ejb.FinderException e) {} //Consume Finder error since I am going away
	}
}
/**
 * ejbActivate method comment
 * @exception java.rmi.RemoteException The exception description.
 */
public void ejbActivate() throws java.rmi.RemoteException {
	_initLinks();
}
/**
 * ejbCreate method for a CMP entity bean
 * @param argName_first java.lang.String
 * @param argName_last java.lang.String
 * @exception javax.ejb.CreateException The exception description.
 * @exception java.rmi.RemoteException The exception description.
 */
public void ejbCreate(java.lang.String argName_first, java.lang.String argName_last) throws javax.ejb.CreateException, java.rmi.RemoteException {
	_initLinks();
	// All CMP fields should be initialized here.
	name_first = argName_first;
	name_last = argName_last;
}
/**
 * ejbLoad method comment
 * @exception java.rmi.RemoteException The exception description.
 */
public void ejbLoad() throws java.rmi.RemoteException {
	_initLinks();
}
/**
 * ejbPassivate method comment
 * @exception java.rmi.RemoteException The exception description.
 */
public void ejbPassivate() throws java.rmi.RemoteException {}
/**
 * ejbPostCreate method for a CMP entity bean
 * @param argName_first java.lang.String
 * @param argName_last java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
public void ejbPostCreate(java.lang.String argName_first, java.lang.String argName_last) throws java.rmi.RemoteException {}
/**
 * ejbRemove method comment
 * @exception java.rmi.RemoteException The exception description.
 * @exception javax.ejb.RemoveException The exception description.
 */
public void ejbRemove() throws java.rmi.RemoteException, javax.ejb.RemoveException {
	_removeLinks();
}
/**
 * ejbStore method comment
 * @exception java.rmi.RemoteException The exception description.
 */
public void ejbStore() throws java.rmi.RemoteException {}
/**
 * Getter method for address
 * @return java.lang.String
 */

public java.lang.String getAddress() {
	return address;
}

/**
 * Getter method for city
 * @return java.lang.String
 */
public java.lang.String getCity() {
	return city;
}
/**
 * getEntityContext method comment
 * @return javax.ejb.EntityContext
 */
public javax.ejb.EntityContext getEntityContext() {
	return entityContext;
}
/**
 * Insert the method's description here.
 * Creation date: (9/24/2001 10:46:00 AM)
 * @return java.lang.String
 */
public String getName_first() {
	return name_first;
}
/**
 * Insert the method's description here.
 * Creation date: (9/24/2001 10:47:09 AM)
 * @return java.lang.String
 */
public String getName_last() {
	return name_last;
}
/**
 * Getter method for name_middle
 * @return java.lang.String
 */
public java.lang.String getName_middle() {
	return name_middle;
}
/**
 * Getter method for state
 * @return java.lang.String
 */
public java.lang.String getState() {
	return state;
}
/**
 * Getter method for zip
 * @return java.lang.String
 */
public java.lang.String getZip() {
	return zip;
}
/**
 * Setter method for address
 * @param newValue java.lang.String
 */

public void setAddress(java.lang.String newValue) {
	this.address = newValue;
}

/**
 * Setter method for city
 * @param newValue java.lang.String
 */
public void setCity(java.lang.String newValue) {
	this.city = newValue;
}
/**
 * setEntityContext method comment
 * @param ctx javax.ejb.EntityContext
 * @exception java.rmi.RemoteException The exception description.
 */
public void setEntityContext(javax.ejb.EntityContext ctx) throws java.rmi.RemoteException {
	entityContext = ctx;
}
/**
 * Insert the method's description here.
 * Creation date: (9/24/2001 10:42:48 AM)
 */
public void setName_first(java.lang.String newValue) {
		this.name_first = newValue;
		}
/**
 * Insert the method's description here.
 * Creation date: (9/24/2001 10:44:34 AM)
 * @param newValue java.lang.String
 */
public void setName_last(String newValue) {
		this.name_last = newValue;
	}
/**
 * Setter method for name_middle
 * @param newValue java.lang.String
 */
public void setName_middle(java.lang.String newValue) {
	this.name_middle = newValue;
}
/**
 * Setter method for state
 * @param newValue java.lang.String
 */
public void setState(java.lang.String newValue) {
	this.state = newValue;
}
/**
 * Setter method for zip
 * @param newValue java.lang.String
 */
public void setZip(java.lang.String newValue) {
	this.zip = newValue;
}
/**
 * unsetEntityContext method comment
 * @exception java.rmi.RemoteException The exception description.
 */
public void unsetEntityContext() throws java.rmi.RemoteException {
	entityContext = null;
}
}

Check List

  1. Create package:  Workbench:Projects:Add
  2. Create BeanGroup, if haven't already done so for Session Beans:  Workbench:EJB:EB panel:Add.
  3. Create Entity Bean:  EJB tab: Enterprise Beans panel:Add >ejb.  Note add fields and methods through wizard.
  4. Add members to Remote Interface (automatic option through wizard; manually add any additional methods).
  5. Add Schema and Map from Beans Panel: Add
  6. Check Schemas:  Beans Panel: Open To > Schema Maps
  7. Export Schema to Database: EJPTab:Beans panel:Open To >Database Schemas :Schema Browser:Schemas panel:Import/Export>Entire
  8. Generate Deployed Code: Bean Panel.
  9. Open To > Server Configuration
  10. Check properties on Server Configuration to be sure DBMS parameters are correct.
  11. Start Naming Service: WTE
  12. Start EJB Server
  13. Run Test Client: EJB Panel