HI ALL.
I have BMP entity bean and
I need to find by "String findByPrimaryKey(
String key_action)"
data field from DB table without calling create(String inAction).
Because I expect/know that datafield (datarecord, what I need)
already exists in DB, therefore I don't want Create/Insert a duplication.
I don't know how I use ejbLoad(). Is "automatic" called this method by EJB-container?
myBeanHome home = (myBeaHome) javax.rmi.PortableRemoteObject.narrow(objref, myBeanHome.class);
/*----------------
home.create("walker");
It creates and inserts duplication.
"walker"-object exists in DB and I need just read it from DB.
-------------------*/
myBean myejb = home.findByPrimaryKey("walker");
String nm = myejb.getName();
//i'm getting here "null"
Some advise please?
my findByPrimaryKey() is typical:
public String ejbFindByPrimaryKey(String key_action) throws ObjectNotFoundException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = getConnection().prepareStatement("SELECT 1 FROM PEOPLE WHERE ACTION = ?");
ps.setString(1, key_action);
rs = ps.executeQuery();
if(rs.next()){
return key_action;
}
else{
throw new ObjectNotFoundException ();
}
}
catch (SQLException ex) {
ex.printStackTrace();
throw new EJBException(ex);
}
}