Posted By:
Mike_Lee
Posted On:
Tuesday, October 29, 2002 07:23 PM
I have some problem with CMP multiple PK, i try my best to write it , but still do notwork here is my code, pls help~ i am using jboss-3.0.0_tomcat-4.0.3 standardjaws.xml ShippingScheduleEJB ShippingSchedule true scheduleNumber scheduleNumber CHAR CHAR(15) batSeq batSeq CHAR CHAR(5) ShippingScheduleBean.java import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingExcepti
More>>
I have some problem with CMP multiple PK,
i try my best to write it , but still do notwork
here is my code, pls help~
i am using jboss-3.0.0_tomcat-4.0.3
standardjaws.xml
ShippingScheduleEJB
ShippingSchedule
true
scheduleNumber
scheduleNumber
CHAR
CHAR(15)
batSeq
batSeq
CHAR
CHAR(5)
ShippingScheduleBean.java
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ejb.EntityContext;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import java.sql.Date;
public abstract class ShippingScheduleBean implements javax.ejb.EntityBean
{ protected EntityContext ctx;
public ShippingSchedulePK ejbCreate(String ScheduleNumber, String batSeq, String carrier) throws CreateException
{ System.out.println("ShippingSchedule Bean " + scheduleNumber + " create");
this.setShippingSchedulePK(scheduleNumber, batSeq);
this.setCarrier(carrier);
}
public void ejbPostCreate(String scheduleNumber, String carrier){}
public abstract ShippingSchedulePK getShippingSchedulePK();
public abstract String getCarrier();
public abstract void setShippingSchedulePK(String scheduleNumber, String batSeq);
public abstract void setCarrier(String carrier);
....
}
ShippingScheduleHomeRemote.java
public interface ShippingScheduleHomeRemote extends javax.ejb.EJBHome {
public ShippingScheduleRemote create(String ScheduleNumber, String batSeq, String carrier) throws RemoteException, CreateException;
public ShippingScheduleRemote findByPrimaryKey (ShippingSchedulePK shippingSchedulePK) throws RemoteException, FinderException;
public Collection findAll() throws RemoteException, FinderException;
}
ShippingScheduleRemote.java
public interface ShippingScheduleRemote extends javax.ejb.EJBObject
{ public ShippingSchedulePK getShippingSchedulePK() throws RemoteException;
public void setShippingSchedulePK(String scheduleNumber, String batSeq) throws RemoteException;
public String getCarrier() throws RemoteException;
public void setCarrier(String carrier) throws RemoteException;
}
import java.io.Serializable;
public class ShippingSchedulePK implements java.io.Serializable
{ public String scheduleNumber;
public String batSeq;
public ShippingSchedulePK(String scheduleNumber, String batSeq)
{ this.scheduleNumber = scheduleNumber;
this.batSeq = batSeq;
}
public ShippingSchedulePK()
{}
public int hashCode()
{ return this.toString().hashCode();
}
public boolean equals(Object o)
{ if (o instanceof ShippingSchedulePK)
{ return toString().equals(((ShippingSchedulePK)o).toString());
}
else
{ return false;
}
}
public String toString()
{ String strConcat = new String(scheduleNumber.trim() + "|" + batSeq.trim());
return strConcat;
}
}
ejb-jar.xml
...
ShippingScheduleEJB
ShippingScheduleHomeRemote
ShippingScheduleRemote
ShippingScheduleBean
Container
ShippingSchedulePK
False
2.x
ShippingScheduleSchema
carrier
DataSource for the test database
jdbc/MySqlDS
javax.sql.DataSource
Container
findAll
SELECT Object(shippingSchedule) FROM ShippingScheduleSchema AS shippingSchedule
...
jbosscmp-jdbc.xml
...
ShippingScheduleEJB
ShippingSchedule
carrier
carrier
CHAR
CHAR(15)
...
AND this is some of the error message that i receive in jboss
10:00:47,970 ERROR [EJBDeployer] Could not deploy file:/usr/local/jboss-3.0.0_tomcat-4.0.3/server/default/deploy/logon.jar
org.jboss.deployment.DeploymentException: Error while creating table; - nested throwable: (java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near '))' at line 1)
<<Less