[jboss-user] [J2EE Design Patterns] - DAO and Entity Beans

Anandnatraj do-not-reply at jboss.com
Fri May 18 04:59:47 EDT 2007


I am using a DAO Insert and trying to load the Remote Entity bean for the record which is just created under a single transaction as below

public MyEntity createSomeInfoMethod()
{
  MyEntityHome entityHome = lookUp("MyEntity");
  long id = SomeDAO.insertRecord(valueObject);
  MyEntity mro = MyEntityHome.findByPrimaryKey(id);
  return mro;
}

createSomeInfoMethod() is a stateless session method under a transaction control.
id is returned as the primaryKey of the record which is inserted using a DAO. (it is not null). But on the next line where I try to find the findByPrimaryKey I am getting following exception

javax.ejb.ObjectNotFoundException: No such entity!


MyEntityHome, MyEntity are the Home and Remote respectively for a CMP Bean. Am I missing anything basically? The HOME is looked up correctly. No issues in that.

Please help.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4046733#4046733

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4046733



More information about the jboss-user mailing list