Hi,
Larkin Lowrey wrote:
>
> I think I've got a RTFM type problem but I can't seem to find the docs
> on-line. I'd appreciate any links which might help.
>
> I'm having a problem with my bean managed entity ejb. On the first
> getXYZ() the container calls ejbLoad() as I would expect. What I didn't
> expect was the container calling ejbStore() after each call to
> getXYZ(). I expected the container to be smarter than that. Is this
> ejbStore() behavior normal?
Yes, if your calls to getXYZ() is in
different transactions (or outside
transactions). If getXYZ() is called
in a transaction, the ejbStore()
should not be called until the
transaction is about to commit.
This way you can do a lot of calls to
a bean within the same transaction
and only have a single ejbStore()
call at the end of the transaction.
> The ejb specs seems to state that the bean
> should be prepared for the container to call ejbStore() at any time and
> that it should write all pending updates to the persistent store. I
> guess I could put a "dirty" flag in the bean but that seems like a
> hack.
It isn't portable, but JBoss supports
such a hack:
Just create a bean method
public boolean isModified()
{
return dirty;
}
and ejbStore() will not be called
unless a call to this method returns
true.
> My next question is how transactions are handled for beans which might
> only be read. It would be a waste of cycles to do a commit in this
> case.
A commit or rollback is needed for
locks to be released, and
Synchronization objects may have been
registered with the transaction, so
we cannot avoid terminating the
transaction.
But if all access to all resources
(including databases) is read-only,
their XAResource.prepare() will all
vote read-only, and second commit
phase will be skipped. This makes
committing a read-only transaction
just as fast as a rollback.
> If I do not specify a trans-attribute for any of the methods for
> this bean, what is the default transaction behavior?
Required.
Best Regards,
Ole Husgaard.
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]