Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Container Managed Persistence PROBLEM for Entity Bean

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to generate a JAR file for a container managed persistence Entity Bean (for weblogic 5.1). I am in a strange situation and does not have any clue about the following error. There is no compilation error for the classes I used. I am giving the classes I used for this purpose. Can any one help me out please.............
C:\WINNT\Profiles\Administrator\.ejbdeployer\provider-projects\OrderEJB\ejb-jar\ejb\entityBean\containerManaged\testing\OrderBeanEOImpl.java:56: incompatible types
found : int
required: ejb.entityBean.containerManaged.testing.OrderPK
pk = bean.custid;
^
1 error
The database table used for this application contains three fields namely, cust_id(int), item_code(varchar2), item_quantity(int).

%%%%%%%%%%%%%%%%%%%%%% Home Interface %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.Collection;
import javax.ejb.*;

public interface OrderHome extends EJBHome {
public Order create(int custid, String itemcode, int quantity) throws RemoteException, CreateException;
public Order findByPrimaryKey(OrderPK pk) throws FinderException, RemoteException;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% Remote Interface %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.sql.*;
import java.rmi.RemoteException;
public interface Order extends javax.ejb.EJBObject {
public void setQuantity(int quantity) throws RemoteException;
public int getCustID() throws RemoteException;
public String getItemCode() throws RemoteException;
public int getQuantity() throws RemoteException;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%% Bean Class %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.rmi.*;
import javax.ejb.*;
import java.sql.*;
public class OrderBean implements EntityBean {
public int custid;
public String itemcode;
public int quantity;
private boolean isModified = false;
public EntityContext entityContext;
public OrderPK ejbCreate(int custid, String itemcode, int quantity) throws CreateException {

this.custid = custid;
this.itemcode = itemcode;
this.quantity = quantity;

//return new OrderPK(custid);
return null;
}
public void ejbPostCreate(int custid, String itemcode, int quantity) throws CreateException {
}
public void ejbActivate() throws RemoteException {
}
public void ejbLoad() throws RemoteException {
}
public void ejbPassivate() throws RemoteException {
}
public void ejbRemove() throws RemoteException, RemoveException {

}
public void ejbStore() throws RemoteException {
if (isModified())
setModified(false);
}
public void setEntityContext(EntityContext context) throws RemoteException {
entityContext = context;
}
public void unsetEntityContext() throws RemoteException {
entityContext = null;
}
public boolean isModified() {
return this.isModified;
}
private void setModified(boolean modified) {
this.isModified = modified;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getCustID() {
return this.custid;
}
public String getItemCode() {
return this.itemcode;
}
public int getQuantity() {
return this.quantity;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% Primary Key Class %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.sql.*;
public class OrderPK implements java.io.Serializable {
public int custid;
public OrderPK() {
}
public OrderPK(int custid) {
this.custid = custid;
}
public boolean equals(Object obj) {
if (obj==null | | !(obj instanceof OrderPK))
return false;
OrderPK pk = (OrderPK)obj;
if (this.custid != pk.custid)
return false;
return true;
}
public int hashCode() {
StringBuffer strB = new StringBuffer();
strB.append(custid);
return strB.toString().hashCode();
}
public String toString() {
String b = "OrderPK[custid=" + custid ;
return b;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------------
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was able to deploy the bean with almost no changes to ur code... the only exception being the entityContext attribute which I changed to a private transient as it is not going to be persisted anyway.
My xmls are pasted below... hope that helps.
Sorry .... I had to delete my xmls as they lost their formatting when i pasted it here somehow and i cant figure out how to get it right. Pls mail me if u still have problems.
Anup

[This message has been edited by anup vachali (edited August 22, 2001).]
 
smitharai
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anup,
Thanks for your response. Would you please mail all the classes and xml files to my yahoo mail address please. My e-mail id is : learner_jsp@yahoo.com
Regards,
Smitha
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"smitharai":
Please follow the rules of the javaranch, I have posted to you another message like this one, your name is not valid, go here please: http://www.javaranch.com/name.jsp
It will take you just a little time, please register with a valid name.
Thanks

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem is related to PrimaryKey problem U better go thru the differences between singlefield primarykey and compund primary key from any ejb book.This will solve ur probleme
Ranga
 
Marcela Blei
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"ranga786":
Your name is not valid, go here please: http://www.javaranch.com/name.jsp
It will take you just a little time, please register with a valid name.
Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic