I have a stateless session bean which uses a BMP entity bean to retrieve data from the database.
My stateless session bean has a method load() which calls getValues() on the entity bean.
Analyzing logs and stepping thru the code, I found out that each and every getValues() call is demarcated by a transaction. I also know that the calling method load() is not in a transaction (used the TransactionHelper to figure that out). Basically a new transaction is created when getValues() is called, and committed when getValues() call is done.
I was under the impression that transactions are required only when data is written to a database (eg setValues()) but not when you read it. Even more, I have set the transaction attribute to "Never", and I am not getting any exceptions as I would have expected.
Am I doing something wrong in my setup or this is the expected behavior of the entity beans?
Here is the ejb-jar.xml config related to my question:
Demarcating a transaction on a entity bean read is normal.
This is to improve performance by ensuring the complete read operation is performed using a single communication channel (socket) between the server and the database.