EJB Transaction

G

gk

This is from Book "Ejb 3.0 In Simple Steps" By Drearntech Press

I have gone through the EJB Transaction Attributes . I know there are
Six transaction attributes we all know REQUIRED ,
REQUIRED_NEW ,MANDATORY , NOT_SUPPORTED, SUPPORTS and NEVER.

My question is on its usage .....see what the Book says ...Here is
the excerpt from the Book



REQUIRED
--------------------------

The REQUIRED transaction operation is required when the method is
involved in some serious data change which needs to be protected by a
transaction.

My Question >> : I'm not sure what does the Book mean by "some
serious data change" ....To me , any data change is a serious
matter :) ....So , this part is not clear. Does anybody have any idea
or real example when this could be useful ? may be in terms of code or
a case study to understand this concept.


MANDATORY
----------------------------

We should use the MANDATORY attribute when our method needs to verify
that the component was invoked within the context of a client-managed
transaction.

My Question >> : Again, "method needs to verify that the component was
invoked within the context of a client-managed transaction" is NOT
quite understandable . What is to be written for this verification in
code level ? may be in terms of code or a case study to understand
this concept.
 
R

Robert Klemme

This is from Book "Ejb 3.0 In Simple Steps" By Drearntech Press

I have gone through the EJB Transaction Attributes . I know there are
Six transaction attributes we all know REQUIRED ,
REQUIRED_NEW ,MANDATORY , NOT_SUPPORTED, SUPPORTS and NEVER.

My question is on its usage .....see what the Book says ...Here is
the excerpt from the Book



REQUIRED
--------------------------

The REQUIRED transaction operation is required when the method is
involved in some serious data change which needs to be protected by a
transaction.

My Question>> : I'm not sure what does the Book mean by "some
serious data change" ....To me , any data change is a serious
matter :) ....So , this part is not clear. Does anybody have any idea
or real example when this could be useful ? may be in terms of code or
a case study to understand this concept.

Basically you need a transaction as soon as you plan to do multiple
changes that should be treated atomically.

http://en.wikipedia.org/wiki/Transaction_processing

Important aspect is ACID properties of TX:

http://en.wikipedia.org/wiki/ACID
MANDATORY
----------------------------

We should use the MANDATORY attribute when our method needs to verify
that the component was invoked within the context of a client-managed
transaction.

My Question>> : Again, "method needs to verify that the component was
invoked within the context of a client-managed transaction" is NOT
quite understandable . What is to be written for this verification in
code level ? may be in terms of code or a case study to understand
this concept.

The wording is a bit misleading. Your EJB container will do the check
for you and not invoke the method at all if not all the prerequisites
are met but rather throw:

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction3.html#62933

Kind regards

robert
 
L

Lew

gk said:
This is from Book "Ejb 3.0 In Simple Steps" By Drearntech Press

I have gone through the EJB Transaction Attributes . I know there are
Six transaction attributes we all know REQUIRED ,
REQUIRED_NEW ,MANDATORY , NOT_SUPPORTED, SUPPORTS and NEVER.

My question is on its usage .....see what the Book says ...Here is
the excerpt from the Book


My Question>> : I'm not sure what does the Book mean by "some
serious data change" ....To me , any data change is a serious

The book was being shamefully imprecise and poorly written. See Robert
Klemme's answer. Bottom line, "serious data change" is not an engineering
concept. "Must participate in a transaction" is. You can determine
objectively whether a given set of changes must occur together or not at all,
and whether one such change is part of such a set that must occur together.
If it is, then a transaction is REQUIRED for that change to be meaningful.
matter :) ....So , this part is not clear. Does anybody have any idea
or real example when this could be useful ? may be in terms of code or
a case study to understand this concept.

The classic transaction example is a monetary exchange. Suppose Gunther
initiates a transfer of one million yuan to the account of Mr. Lew. Clearly
the removal of one million yuan from Gunther's account and the deposit into
Mr. Lew's must occur as a transaction, together or not at all. The two banks
presumably use different data stores and business systems, so a single-phase
commit is out of the question. One can and should require that the withdrawal
and the deposit occur within an XA (or similar) transaction.
MANDATORY
----------------------------

We should use the MANDATORY attribute when our method needs to verify
that the component was invoked within the context of a client-managed
transaction.

My Question>> : Again, "method needs to verify that the component was
invoked within the context of a client-managed transaction" is NOT
quite understandable . What is to be written for this verification in
code level ? may be in terms of code or a case study to understand
this concept.

What a terrible book.
<http://www.java-tips.org/java-ee-tips/enterprise-java-beans/introduction-to-the-java-transactio.html>
(found after two minutes with Google - have you tried that?)
explains it better. So does (gasp!) the official Java EE tutorial, of all things:
<http://download.oracle.com/javaee/6/tutorial/doc/bncih.html>
in particular,
<http://download.oracle.com/javaee/6/tutorial/doc/bncij.html#bncik>

The difference is that REQUIRED asks the container to start a transaction if
there isn't one, MANDATORY throws an exception if there isn't one.
 
A

Arved Sandstrom

Lew said:
gk said:
This is from Book "Ejb 3.0 In Simple Steps" By Drearntech Press [ SNIP ]
MANDATORY
----------------------------

We should use the MANDATORY attribute when our method needs to verify
that the component was invoked within the context of a client-managed
transaction.

My Question>> : Again, "method needs to verify that the component
was invoked within the context of a client-managed transaction" is
NOT quite understandable . What is to be written for this
verification in code level ? may be in terms of code or a case study
to understand this concept.

What a terrible book.
<http://www.java-tips.org/java-ee-tips/enterprise-java-beans/introduction-to-the-java-transactio.html>
(found after two minutes with Google - have you tried that?)
explains it better. So does (gasp!) the official Java EE tutorial,
of all things:
<http://download.oracle.com/javaee/6/tutorial/doc/bncih.html> in
particular,
<http://download.oracle.com/javaee/6/tutorial/doc/bncij.html#bncik>

The difference is that REQUIRED asks the container to start a
transaction if there isn't one, MANDATORY throws an exception if
there isn't one.

The main problem with a lot of programming books is that they are
unnecessary. As you pointed out, the OP hasn't asked any questions in this
thread that aren't answered (and answered well) by some of the commonly-used
online references. A lot of books cover the same ground - *at the same
level* - as these online tutorials; their authors really don't have much if
anything useful to add, so in desperation they reword the original
material...usually mangling the sense of it.

The main recommendation I'd make is always start with the (semi-)official
online references. Given reasonable Google fu the "accepted" references for
a majority of programming problems, and for no small percentage of software
engineering issues, appear on the first few pages of Google results. It can
sometimes be useful to ask on a NG such as this whether a found link
actually is a good one.

I'm not knocking software development books - I happen to have a few myself.
:) However not a single one of them purchased in the last 5 years has had
anything to do directly with J2EE/Java EE. I've got no books on any of that
except for a creaky edition of Java Servlets that's about 8 years old. Yet
well over half of my bread and butter work is J2EE/Java EE, and I sure don't
have everything I need to know in my head. There simply is very little need,
for any level of developer, for servlet or web service or EJB books. I can
look back and recognize that when I was still thinking I needed those kinds
of books that many of them did me a disservice.

As an aside, sometimes I'd like to ask the author of an API and of an
implementation for that API why they then felt the need to write an O'Reilly
or Wrox book on that API - does their official API documentation (and other
related documentation like specifications)suck so bad then? They must think
so.

AHS
 
R

Robert Klemme

Lew said:
gk said:
This is from Book "Ejb 3.0 In Simple Steps" By Drearntech Press [ SNIP ]
MANDATORY
----------------------------

We should use the MANDATORY attribute when our method needs to verify
that the component was invoked within the context of a client-managed
transaction.

My Question>> : Again, "method needs to verify that the component
was invoked within the context of a client-managed transaction" is
NOT quite understandable . What is to be written for this
verification in code level ? may be in terms of code or a case study
to understand this concept.

What a terrible book.
<http://www.java-tips.org/java-ee-tips/enterprise-java-beans/introduction-to-the-java-transactio.html>
(found after two minutes with Google - have you tried that?)
explains it better. So does (gasp!) the official Java EE tutorial,
of all things:
<http://download.oracle.com/javaee/6/tutorial/doc/bncih.html> in
particular,
<http://download.oracle.com/javaee/6/tutorial/doc/bncij.html#bncik>

The difference is that REQUIRED asks the container to start a
transaction if there isn't one, MANDATORY throws an exception if
there isn't one.

The main problem with a lot of programming books is that they are
unnecessary. As you pointed out, the OP hasn't asked any questions in this
thread that aren't answered (and answered well) by some of the commonly-used
online references. A lot of books cover the same ground - *at the same
level* - as these online tutorials; their authors really don't have much if
anything useful to add, so in desperation they reword the original
material...usually mangling the sense of it.

I couldn't agree more.
The main recommendation I'd make is always start with the (semi-)official
online references. Given reasonable Google fu the "accepted" references for
a majority of programming problems, and for no small percentage of software
engineering issues, appear on the first few pages of Google results. It can
sometimes be useful to ask on a NG such as this whether a found link
actually is a good one.

Adding to that: In the case of Java technologies I have found Sun
specifications to be very readable while not being overly lengthy
(compared to some other stuff published by some official committee). I
would consider those specs better points of reference than the types of
books you mention even though in the case of JEE it can be a bit
difficult to find the right specification to look into just because
there are so many of them. :)
I'm not knocking software development books - I happen to have a few myself.
:) However not a single one of them purchased in the last 5 years has had
anything to do directly with J2EE/Java EE. I've got no books on any of that
except for a creaky edition of Java Servlets that's about 8 years old. Yet
well over half of my bread and butter work is J2EE/Java EE, and I sure don't
have everything I need to know in my head. There simply is very little need,
for any level of developer, for servlet or web service or EJB books. I can
look back and recognize that when I was still thinking I needed those kinds
of books that many of them did me a disservice.

As an aside, sometimes I'd like to ask the author of an API and of an
implementation for that API why they then felt the need to write an O'Reilly
or Wrox book on that API - does their official API documentation (and other
related documentation like specifications)suck so bad then? They must think
so.

I would rather assume that there is just a market for such books, i.e.
there are enough people that will buy the book "from the author of X"
much the same as there are enough people to jump on the next buzzword
hype. There is also the sort of people who seem to feel more
comfortably having a book about a topic sitting on their shelve instead
of resorting to a collection of links, PDF's or search engines. I
believe they think they can then tell themselves "I have all knowledge
about Y at my hands".

Kind regards

robert
 
G

gk

Lew said:
gk wrote:
This is from Book "Ejb 3.0 In Simple Steps" By Drearntech Press [ SNIP ]
MANDATORY
----------------------------
We should use the MANDATORY attribute when our method needs to verify
that the component was invoked within the context of a client-managed
transaction.
My Question>>   : Again, "method needs to verify that the component
was invoked within the context of a client-managed transaction"   is
NOT quite understandable . What is to be written for this
verification in code level ? may be in terms of code or a case study
to understand this concept.
What a terrible book.
<http://www.java-tips.org/java-ee-tips/enterprise-java-beans/introduct....>
(found after two minutes with Google - have you tried that?)
explains it better.  So does (gasp!) the official Java EE tutorial,
of all things:
<http://download.oracle.com/javaee/6/tutorial/doc/bncih.html>  in
particular,
<http://download.oracle.com/javaee/6/tutorial/doc/bncij.html#bncik>
The difference is that REQUIRED asks the container to start a
transaction if there isn't one, MANDATORY throws an exception if
there isn't one.
The main problem with a lot of programming books is that they are
unnecessary. As you pointed out, the OP hasn't asked any questions in this
thread that aren't answered (and answered well) by some of the commonly-used
online references. A lot of books cover the same ground - *at the same
level* - as these online tutorials; their authors really don't have much if
anything useful to add, so in desperation they reword the original
material...usually mangling the sense of it.

I couldn't agree more.
The main recommendation I'd make is always start with the (semi-)official
online references. Given reasonable Google fu the "accepted" references for
a majority of programming problems, and for no small percentage of software
engineering issues, appear on the first few pages of Google results. It can
sometimes be useful to ask on a NG such as this whether a found link
actually is a good one.

Adding to that: In the case of Java technologies I have found Sun
specifications to be very readable while not being overly lengthy
(compared to some other stuff published by some official committee).  I
would consider those specs better points of reference than the types of
books you mention even though in the case of JEE it can be a bit
difficult to find the right specification to look into just because
there are so many of them. :)
I'm not knocking software development books - I happen to have a few myself.
:) However not a single one of them purchased in the last 5 years has had
anything to do directly with J2EE/Java EE. I've got no books on any of that
except for a creaky edition of Java Servlets that's about 8 years old. Yet
well over half of my bread and butter work is J2EE/Java EE, and I sure don't
have everything I need to know in my head. There simply is very little need,
for any level of developer, for servlet or web service or EJB books. I can
look back and recognize that when I was still thinking I needed those kinds
of books that many of them did me a disservice.
As an aside, sometimes I'd like to ask the author of an API and of an
implementation for that API why they then felt the need to write an O'Reilly
or Wrox book on that API - does their official API documentation (and other
related documentation like specifications)suck so bad then? They must think
so.

I would rather assume that there is just a market for such books, i.e.
there are enough people that will buy the book "from the author of X"
much the same as there are enough people to jump on the next buzzword
hype.  There is also the sort of people who seem to feel more
comfortably having a book about a topic sitting on their shelve instead
of resorting to a collection of links, PDF's or search engines.  I
believe they think they can then tell themselves "I have all knowledge
about Y at my hands".


I love books because they carry example code snippets.
 
A

Arved Sandstrom

gk said:
On 15.08.2010 16:17, Arved Sandstrom wrote: [ SNIP ]
I'm not knocking software development books - I happen to have a
few myself. :) However not a single one of them purchased in the
last 5 years has had anything to do directly with J2EE/Java EE.
I've got no books on any of that except for a creaky edition of
Java Servlets that's about 8 years old. Yet well over half of my
bread and butter work is J2EE/Java EE, and I sure don't have
everything I need to know in my head. There simply is very little
need, for any level of developer, for servlet or web service or EJB
books. I can look back and recognize that when I was still thinking
I needed those kinds of books that many of them did me a
disservice.
As an aside, sometimes I'd like to ask the author of an API and of
an implementation for that API why they then felt the need to write
an O'Reilly or Wrox book on that API - does their official API
documentation (and other related documentation like
specifications)suck so bad then? They must think so.

I would rather assume that there is just a market for such books,
i.e. there are enough people that will buy the book "from the author
of X" much the same as there are enough people to jump on the next
buzzword hype. There is also the sort of people who seem to feel more
comfortably having a book about a topic sitting on their shelve
instead of resorting to a collection of links, PDF's or search
engines. I believe they think they can then tell themselves "I have
all knowledge about Y at my hands".

I love books because they carry example code snippets.

There is no shortage of online code snippets. The references that Lew
provided have them too.

YMMV, but I've found that book code snippets are often bloated, because the
author needs them that way to bulk up his or her book. Online article
authors don't feel the same need; in fact they often work diligently to pare
down a code snippet into its essence so that their verbiage isn't too great.

Like I said, my _main_ point is that a lot of these books are unnecessary.
You haven't asked anything so far (in this or other threads) that you have
needed a book for; the online references would have sufficed. And let me ask
you this, if their code snippets are so handy, why didn't those answer your
questions? No reflection on you (we've all been there), but your questions
have not been difficult ones yet.

To reiterate, I'm not saying to abandon and disrespect all books. Just save
yourself some time and money by doing thorough Web searches first. Much of
the best reference material, and most of the most up-to-date material, is on
the Web, and sometimes *only* on the Web.

AHS
 
A

Alan Gutierrez

Arved said:
To reiterate, I'm not saying to abandon and disrespect all books. Just save
yourself some time and money by doing thorough Web searches first. Much of
the best reference material, and most of the most up-to-date material, is on
the Web, and sometimes *only* on the Web.

The majority of the wooden paving stones that buckle the floorboards of
the computer section your local Books-a-Million are non-sense of the 21
Days variety that is as useful as the map of Chicago in "Complete and
Comprehensive" 1:1 scale.

The handful of computer texts that were actually worth a read in my life
fit on a single shelf. Most of what I've learned, I've learned from
online documentation, questions, and application. I generally use text
to learn a new language "Programming Perl" or learn a new concept "Java
Concurrency in Practice". Otherwise, I look for online documentation and
a lively community.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top