• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entity Bean ejbCreate method

 
Loka Nalla
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am bit confusion on entity bean creation. Is my understanding below correct?

1) ejbLoad/ejbStore is called by container only when the client calls component business methods.

2) when create is called by client, the container will not call ejbStore but rather it directly inserts record into the database.


Thank you
Loka
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are correct.

1. ejbLoad/ejbStore called by container before and after executing buisness methods or you can say, before and after bean data gets updated.

2. ejbCreate will be called by container on calling create(..) in home interface. And calling ejbLoad() doesn't make sense in this case, because there is no data yet to refresh bean state. Also calling ejbStore(0 is not required because, client calls create(..) method in home to create a new record and not for updating the existing record.

After ejbCreate() method completes, container call ejbPostCreate() to finish your intialize process like, updating dependent beans.

hth,
 
Rajan Murugan
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


1) ejbLoad/ejbStore is called by container only when the client calls component business methods.


This is one scenario when ejbLoad/ejb?Store is called by container.The container may call these methods n number of times as and when it wants to synchronize the bean data with the data of the entity.
So this is not the onlytime they are called
[ November 18, 2006: Message edited by: Rajan Murugan ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would add something in here.

The container will call ejbStore before calling ejbPassivate, and on a server that does active passivation, ejbPassivate is called immediately after ejbPostCreate.

I put together a neat multimedia tutorial the creates a BMP, and just codes a System.out.println("Im in ejbXYZ method"); for each of the methods of the BMP. I then load the BMP on the server, and do thing like create it and call business methods. As this happens, you see exactly what methods are called when.

If you have any doubts about when a certain ejb method is called, you should check it out. People are always blown away when the EJB invokes an ejbLoad and an ejbStore for a simple getter method.

How EJB Lifecycle Methods REALLY work.

Cheers!

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic