EntityPKHome pkHome = (EntityPKHome) ctx.lookup("nextgen.EntityPK");
assertTrue("pkHome != null", pkHome != null);
getLog().debug("ok");
getLog().debug(++test+"- "+"Calling find on the home...");
EntityPK pkBean = null;
// Let's try to find the instance
try {
pkBean = pkHome.findByPrimaryKey(new AComplexPK(true, 10, 100, 1000.0, "Marc"));
} catch (Exception e) {
getLog().debug("not found");
getLog().debug(++test+"- "+"Did not find the instance will create it...");
pkBean = pkHome.create(true, 10,100, 1000.0, "Marc");
}
assertTrue("pkBean != null", pkBean != null);
getLog().debug("ok");
getLog().debug(++test+"- "+"Retrieving other field...");
assertTrue("pkBean.getOtherField() == 0", pkBean.getOtherField() == 0);
getLog().debug(++test+"- "+"Setting it to 4...");
pkBean.setOtherField(4);
getLog().debug("ok");
getLog().debug(++test+"- "+"Findind it again ... ") ;
// Now we should be able to find it
pkBean = pkHome.findByPrimaryKey(new AComplexPK(true, 10, 100,1000.0, "Marc"));
assertTrue("pkBean != null", pkBean != null);
getLog().debug("ok");
// check if the other field has been saved
getLog().debug(++test+"- "+"Retrieving other field again, should be 4...");
int newValue = pkBean.getOtherField();
assertTrue("pkBean.getOtherField() == 4", newValue == 4);
getLog().debug("4, ok");
// Get a new EJBObject for this guy
// Now we should be able to find it
getLog().debug(++test+"- gettting a new reference ... ") ;
EntityPK pkBean2 = pkHome.findByPrimaryKey(new AComplexPK(true, 10, 100,1000.0, "Marc"));
assertTrue("findByPrimaryKey AComplexPK", pkBean2 != null);
getLog().debug("ok");
getLog().debug(++test+"- Retrieving other field again, should be 4...");
int newValue2 = pkBean2.getOtherField();
assertTrue("Retrieving other field again, should be 4...", newValue2 == 4);
// Now remove it
getLog().debug(++test+"- "+"Removing the bean...");
pkBean.remove();