• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Entity Bean ejbCreate method

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and cow tipper
Posts: 5006
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Let's go to the waterfront with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic