Forums Register Login

Transactions... why and how?

+Pie Number of slices to send: Send
Hi,
I know what trasactions are for DB. But I am having hard time to understand what they do in EJB. So my multiple questions:
1) I have DB (like MySQL) configured for use on some App server. I put my beans (entity beans) and run various methods on my entity beans. Will the container use my DB server transactions .. mhm automatically?
2) The same question but beans are with BMT. I will have to implement those transaction starting calls communicating with my DB driver?
3) I have my entity beans and I want them on some persistant store that is not DB (files!). Can I use entity CMP CMT CMR ? I guess I will have to implement something for my "files" so that container accept it as transactional permanent store?
4) If I have my bean set his data member (which is not virtual field!) to some value in transactional call (like a = 4 .. If I rollback transaction will container automatically restore my data member (which is not field!) to his previous state? I guess not... I have to implement that SyncronizedSession or use EjbLoad.. Right?

If you have answer to any of these please tell me! I love you all.
+Pie Number of slices to send: Send
The container will use the capabilities of the database to make the commit or rollback in both CMT and BMT. The database must support transactions for it to work.
Best Regards
/Magnus
+Pie Number of slices to send: Send
Are you sure about BMT?
+Pie Number of slices to send: Send
Hi Vladas,
1) Yes, but based on the transaction attributes you put in the DD and as far as your DB is supported by your specific EJB container.
2) Entity beans do not support BMT !
3) It's vendor specific (as the DB support)
4) You're right, you'll have to use ejbLoad to restore them. Don't forget that SyncronizedSession is reserved to SESSION beans (stateful).
Best,
Phil.
+Pie Number of slices to send: Send
hi vlada, magnus and phill,
Let me very with you guys my understanding about transaction in EJB and DB. Does a database have to support trasaction in order to make transaction in EJB to work? in another words, is it correct that transaction in EJB always works, does not care whether the database support trasaction or not and it has nothing to do with database transaction support feature? sorry if i could make myself clear.
also vladas, could you please elaborate your last question? you have raised very interesting points here.
namaste
+Pie Number of slices to send: Send
Philippe,
Entity beans do not, but session beans do support BMT. So in BMT case we have to implement those transaction calls ourselves? Hey, that means we just found another use for BMT! That is if container can't work with my DB or whatever "persistent store", I can write BMT beans (uh oh, ok session only) and do it myself. Wait.. no entity beans ... that is no good.
By the way I forgot. Do stateless beans support transactions at all ?
+Pie Number of slices to send: Send
Namaste,
As I understood from Philippe answer CMT will restore bean state in the database (if it is CMP). Any other non-managed by container field ain't gonna be restored. We have to do it in ejbLoad (entity beans) or after... (stateless session beans).
I wonder how CMT works with BMP (bean managed persistance) entity beans???
+Pie Number of slices to send: Send
Hi Vladas,

Entity beans do not, but session beans do support BMT. So in BMT case we have to implement those transaction calls ourselves? Hey, that means we just found another use for BMT! That is if container can't work with my DB or whatever "persistent store", I can write BMT beans (uh oh, ok session only) and do it myself.


Yes, AFAIK BMT sessions may call CMT entity business and home business methods. And as far as the trans attributes set for the entity bean methods are "Required" or "Mandatory", the called methods of the entity bean will execute within your BMT context.
Should be confirmed by Kathy or Valentin though, because I may be wrong .
Best,
Phil.
+Pie Number of slices to send: Send
 

Originally posted by Vladas Razas:

By the way I forgot. Do stateless beans support transactions at all ?


yep, they support both CMT (declarative in DD) and BMT. One of the difference stateLESS from stateFUL though is that for stateLESS bean every method should finish transaction before method finishes, while for stateFUL this is not a mandatory and one transaction can be spreaded over several methods calls which come from client. (But this is a bad idea, since bean has to be kept in memory while in transaction, so if you forgot to call method with commit() or rollback(), then you just spent memory and EJB container is not happy of this).
Cheers!!!
+Pie Number of slices to send: Send
Hi folks,

Originally posted by Mikalai Zaikin:

yep, they support both CMT (declarative in DD) and BMT. One of the difference stateLESS from stateFUL though is that for stateLESS bean every method should finish transaction before method finishes, while for stateFUL this is not a mandatory and one transaction can be spreaded over several methods calls which come from client. (But this is a bad idea, since bean has to be kept in memory while in transaction, so if you forgot to call method with commit() or rollback(), then you just spent memory and EJB container is not happy of this).
Cheers!!!


Is forgetting commit() or rollback() not a problem? What is the point of even starting a trasaction If that transaction is not committed or rollback?the work associated with that trasaction is not completed, right?
namaste
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 798 times.
Similar Threads
My SCEA Part 1Study Notes
My Study Notes
A basic Question on ejbLoad and ejbStore
MDB starts before Queue send is commited
BMT with Entity beans
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:25:51.