Tuesday 12 May 2009

1-How to Develop Container-Managed-Relationships

This article is about how I managed to build CMR Entity Beans using the Developing Container-Managed Relationships example of tinptB ‘s Blog: EJB in 21 Days: http://ejbvn.wordpress.com/
I appreciate her excellent English, which makes a soothing effect while trying to break through difficulties.

TINPTB’s work for the 12th Day misses some deployment descriptor scripts which she indicated with “. . . “ .
There also the name problem related to ‘order’ which is actually a key word and gets mixed. Jndi.properties is also missing in this example. Without any further aloboration, follows my solution below full and completely working with: Jdeveloper 11g(only the client not the deployment), WebLogic10.3, wlfullclient5, apache-ant-1.7.1 and mysql-essential-5.1.30-win32, mysql-connector-java-5.0.8 and Toad for MySQL 4.1 Freeware.

FILE OrderARSHome.java
package cmrex;

import java.util.*;
import java.rmi.*;
import javax.ejb.*;
public interface OrderARSHome extends EJBHome {
/* Create methods */
public OrderARS create(String studentId,
String status, double amount) throws CreateException, RemoteException;
/* Finder methods */
public OrderARS findByPrimaryKey(String key)
throws FinderException, RemoteException;
}

FILE OrderARS.java
package cmrex;

import java.util.*;
import java.rmi.*;
import javax.ejb.*;
public interface OrderARS extends EJBObject{
public String getOrderId()
throws RemoteException;
public String getStudentId()
throws RemoteException;
public void setStudentId(String studentId)
throws RemoteException;
public double getAmount()
throws RemoteException;
public void setAmount(double amount)
throws RemoteException;
public java.sql.Timestamp getOrderDate()
throws RemoteException;
public void setOrderDate(java.sql.Timestamp date)
throws RemoteException;
public String getStatus()
throws RemoteException;
public void setStatus(String status)
throws RemoteException;
public void addLineItem(String courseId, double fee)
throws RemoteException;
public Collection getOrderLineItems()
throws RemoteException;
}