I try my best to make the EJB work,
here is my code, pls help~
i am using jboss-3.0.0_tomcat-4.0.3
standardjaws.xml
<enterprise-beans>
<entity>
<ejb-name>ShippingScheduleEJB</ejb-name>
<table-name>ShippingSchedule</table-name>
<pk-constraint>true</pk-constraint>
<cmp-field>
<field-name>scheduleNumber</field-name>
<column-name>scheduleNumber</column-name>
<jdbc-type>CHAR</jdbc-type>
<sql-type>CHAR(15)</sql-type>
</cmp-field>
<cmp-field>
<field-name>batSeq</field-name>
<column-name>batSeq</column-name>
<jdbc-type>CHAR</jdbc-type>
<sql-type>CHAR(5)</sql-type>
</cmp-field>
</entity>
</enterprise-beans>
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
...
<entity>
<ejb-name>ShippingScheduleEJB</ejb-name>
<home>ShippingScheduleHomeRemote</home>
<remote>ShippingScheduleRemote</remote>
<ejb-class>ShippingScheduleBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>ShippingSchedulePK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>ShippingScheduleSchema</abstract-schema-name>
<cmp-field><field-name>carrier</field-name></cmp-field>
<primkey-field>scheduleNumber</primkey-field-->
<security-identity><use-caller-identity/></security-identity>
<resource-ref>
<description>DataSource for the test database</description>
<res-ref-name>jdbc/MySqlDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT Object(shippingSchedule) FROM ShippingScheduleSchema AS shippingSchedule</ejb-ql>
</query>
</entity>
...
jbosscmp-jdbc.xml
...
<entity>
<ejb-name>ShippingScheduleEJB</ejb-name>
<table-name>ShippingSchedule</table-name>
<cmp-field>
<field-name>carrier</field-name>
<column-name>carrier</column-name>
<jdbc-type>CHAR</jdbc-type>
<sql-type>CHAR(15)</sql-type>
</cmp-field>
</entity>
...
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)
here is my code, pls help~
i am using jboss-3.0.0_tomcat-4.0.3
standardjaws.xml
<enterprise-beans>
<entity>
<ejb-name>ShippingScheduleEJB</ejb-name>
<table-name>ShippingSchedule</table-name>
<pk-constraint>true</pk-constraint>
<cmp-field>
<field-name>scheduleNumber</field-name>
<column-name>scheduleNumber</column-name>
<jdbc-type>CHAR</jdbc-type>
<sql-type>CHAR(15)</sql-type>
</cmp-field>
<cmp-field>
<field-name>batSeq</field-name>
<column-name>batSeq</column-name>
<jdbc-type>CHAR</jdbc-type>
<sql-type>CHAR(5)</sql-type>
</cmp-field>
</entity>
</enterprise-beans>
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
...
<entity>
<ejb-name>ShippingScheduleEJB</ejb-name>
<home>ShippingScheduleHomeRemote</home>
<remote>ShippingScheduleRemote</remote>
<ejb-class>ShippingScheduleBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>ShippingSchedulePK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>ShippingScheduleSchema</abstract-schema-name>
<cmp-field><field-name>carrier</field-name></cmp-field>
<primkey-field>scheduleNumber</primkey-field-->
<security-identity><use-caller-identity/></security-identity>
<resource-ref>
<description>DataSource for the test database</description>
<res-ref-name>jdbc/MySqlDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<query>
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql>SELECT Object(shippingSchedule) FROM ShippingScheduleSchema AS shippingSchedule</ejb-ql>
</query>
</entity>
...
jbosscmp-jdbc.xml
...
<entity>
<ejb-name>ShippingScheduleEJB</ejb-name>
<table-name>ShippingSchedule</table-name>
<cmp-field>
<field-name>carrier</field-name>
<column-name>carrier</column-name>
<jdbc-type>CHAR</jdbc-type>
<sql-type>CHAR(15)</sql-type>
</cmp-field>
</entity>
...
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)