Hey Kartik, Entity beans(CMP & BMP) provides objectified representation of data in underlying datastore, they are always transactional meaning,whenever you invoke any method on them its always executed within Transaction. Main idea of having entity bean is DATA PERSISTANCE & DATA MANIPULATION through java objects, hiding the complexity of DB Operations like queries,Transactions etc... Session Beans however are transaction aware, they represent process / workflow.
I hope this helps, otherwise Ping Javaranch one more time.
I would suggest Read Topic from Oreilly(Richard Manson) & Head First EJB
Joined: Sep 12, 2005
Hey Shrini, Thanks for prompt reply.. I got ur point that entity beans are only meant for Transactional processes... and in session bean u can have transactional process as well as non-transactional processes...
but even though my question remain same... if transaction are associated with the entitt beans than why cant we use BMT???
So we can reduce the scope of the transaction if Sun doesn't want to disturb the lifecycle of entity bean than it could have given BMT entity bean with restriction that one can reduce the scope of transaction but cant expand it to more than 1 method....So its like special kind of bean managed transaction...
Rather it would be a good idea to provide this extra feature to enity bean as the are always involved with transaction.... and sometimes u just want a part of the method to be in transaction .. not just the whole method... and sometimes u want to put more than one transaction in just 1 method... so in this case BMT entity bean could be a good idea...
but Why does SUN Microsys. not provided this feature of BMT in entity bean...??
Originally posted by Kartik Patel: but can someone tell me valid reason of having just CMT for entity bean..
Dear Kartik, The purpose of the entity bean is to represent some data on the persistence store, provided that the container is responsible for synchronizing the entity instance's state with that store. for example, if a client is calling a business method on the entity bean, the container calls ejbLoad() before the execution of the method, and calls ejbStore() after the method execution has finished and before the transaction is commited. So, If you want the entity bean to be BMT, then you should handle the entity's state synchronization by calling ejbLoad() and ejbStore() along with transaction control statements (i.e. begin, commit). In that case, you are defeating one of the major services that the EJB container provides and entity beans exist for, which is providing a simple OO view of some entities stored in the persistent storage. That said, if you need to implement these services yourself, then you sould consider writing a POJO to access the persistence store.
Best regards, [ December 14, 2005: Message edited by: Nadeem Awad ]
Share Knowledge to gain it.<br /> <br />SCJP 1.2, SCDJWS 1.4, SCWCD 1.4, SCBCD 1.3, ICAD