Janne Mattila wrote:EJB supports declarative transactions. You still have to think about transactions. You still have to declare where and what type of transactions you want. What seems to be forgotten is that good patterns are more than an code design or sample code. They should describe when the pattern is applicable. The trade-offs and typical results of using the pattern. What parts may be altered without breaking the pattern. And any known uses of the pattern.Now, one could think about fiddling with transaction settings, maybe fetching data for record r1 could be done in a separate transaction to fetching data for corresponding artists A1. Maybe user would not care if a1 shows modifications by another transaction while r1 does not. Maybe that would be quite a rare condition. Or maybe that's not acceptable or wanted at all?The bottom line is that using (at least to me) very intuitive and common practises you still end up with concurrency problems using EJBs, even in this naive case. I was a bit surprised about this actually. And am curious, is this "expected" and normal behaviour, or should I have done something differently. And I am not buying into that I should have demarcated transactions somewhere else than the session facade, or that I should even have to spend lot of time thinking about transaction handling in such a simple case to get it "working". Your case would be simple if it were read only. However, it's not and that makes it complex. This isn't unique to EJB or solved magically by EJB or any other technology (with the possible exception of some AI driven design tool). This is basic concurrency and a classic case of deadlock as explained in any introductory text on database design. If there are n updates in n transactions or n updates in 1 transaction the performance will be about the same for most modern databases. The cost of a transaction is proportional to the amount of work performed during the transaction. As I said above, EJBs don't remove the worry of transactions. They offer declarative transactions. That may not seem like much with a single database in an non clustered server. Add multiple data sources and clustering and it's quite a lot of complexity hidden behind the bean interface.Besides, I was speculating about a situation where facade.getDataForArtistAndRecord() would be split to separate methods facade.getDataForArtist() facade.getDataForRecord() there's of course the added remote calls, which the session facade was meant to minimize (my original point). Using UserTransaction doesn't cost you anything except being able to declare transaction settings at bean deployment time. You don't lose 2 phase commit, declarative security, clustering or any other benefit of EJB except decarative transactions for one bean. By assuming that a session facade with one overall transaction was the only useful pattern. --Victor =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
|
- Re: How to avoid database deadlocks? Juan Pablo Lorandi
- Re: How to avoid database deadlocks? Janne Mattila
- Re: How to avoid database deadlocks? Victor Langelo
- Re: How to avoid database deadlocks? Janne Mattila
- Re: How to avoid database deadlocks? Victor Langelo
- Re: How to avoid database deadlocks? Janne Mattila
- Re: How to avoid database deadlocks? Victor Langelo
- Re: How to avoid database deadlocks? Janne Mattila
- Re: How to avoid database deadlocks? Victor Langelo
- Re: How to avoid database deadlocks? Janne Mattila
- Re: How to avoid database deadlocks? Victor Langelo
- Re: How to avoid database deadlocks? Janne Mattila
- Re: How to avoid database deadlocks? Victor Langelo
- Re: How to avoid database deadlocks? Johan Eltes
- Re: How to avoid database deadlocks? Janne Mattila
- Re: How to avoid database deadlocks? Janne Mattila
