• Post Reply Bookmark Topic Watch Topic
  • New Topic

when the ejbStore() is called

 
vj_d
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've the following situation,
I have a stateless session bean, S1
and, Two entity beans E1 and E2.
E1 has a reference (a foreign key column) to the primary key of E2.
Now, in the remote method of S1, I do the following steps,
1. set the E2 reference in E1 as null (this would be persisted to the database in the ejbStore() method of E1)
2. Remove the E2.
Both the entity beans has <trans-attribute>Required</trans-attribute>
NOw my question is,
When will the ejbStore() of E1 will be called, right after the first step in the remote method of S1 or at the end of the transaction (ie., the when the remote method of S1 returns?)
If the ejbStore() methods of both the entities are called before the method in S1 finishes, then what will be the order of ejbStore() methods in E1 and E2.

I've not tried the above scenario.
Any kind of input would be of great help.
Thanx,
vijay
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I�m using WebLogic and in it�s examples they show a great way to find out about method callings in EJBs, here what they do:
they declare a boolean flag:
private final static boolean VERBOSE = true;
then they build a method log:
<code>
private void log(String s)
{
if (VERBOSE) System.out.println(s);
}
</code>
and the ejb id:
<code>
private String id()
{
return "" + System.identityHashCode(this) + ", PK = " +
(String) ((ctx == null) ? "nullctx"
: ((ctx.getPrimaryKey() == null ?
"null" : ctx.getPrimaryKey().toString())));
}
</code>
and then at all methods(ex):
<code>
public void setEntityContext(EntityContext ctx)
{
log("setEntityContext called");
this.ctx = ctx;
}
public void ejbPassivate() {
log("AccountBean.ejbPassivate (" + id() + ")");
}
public void ejbLoad() {
log("AccountBean.ejbLoad (" + id() + ")");
}
public void ejbStore() {
log("AccountBean.ejbStore (" + id() + ")");
}
</code>
etc...
I think this can help you.

[This message has been edited by Marcos Maia (edited July 27, 2001).]
 
Matt Midcap
Sheriff
Posts: 440
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vj_d",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!