Are you using the Entity per Transaction or Entity per Container?
Hi, thanks for the answer.
All the CMP's are in the same container.
The transaction is initiated in a session facade. All entity-beans have the transaction attribute "Required" and are accessed localy. Furthermore we are using container managed transaction.
Is there a way to see in CMT-Mode, when a container starts a new transaction?
ioparras question was which container configuration did you use for your entity beans? The Standard CMP 2.0 or the entity per transaction config stuff?
Are you calling finders between your entity-bean access? If so the cmp engine must write back any changed data before issuing the finder call. So keep the right order in you tx - first all read operations - then write (update/create/remove).
the beans are in the "Standard CMP 2.x Container" (the first one configured in ...server/default/conf/standardjboss.xml)
"entity per transaction config stuff"
Which one is that?
yes I call few finder methods on the home interface of one of the entity-beans.
There is no write access to those beans at all (not during this one transaction)
It is a huge bunch of rows from a database table I have to iterate through. One of the finder called is findAll() and there are about 4000 rows in the table.
I know it's a good candidate for readonly beans, but the table is sometimes accessed in write mode too.
We used CachedRowset's before (accessed from a session bean (in a separate DB-Class)) to read the table and some sort of object cache within the session bean. It's very fast, but can become inconsistent, when things changes.
...calling finders between your entity-bean access? If so the cmp engine must write back any changed data before issuing the finder call
Yes I know this from the EJB spec. (did never understand why it happens, when nothing changes)
We hopped, that JBoss writes changed entities only back to the table (similar to using isModified() in BMP)
Is there a way to prevent the beans from beeing (unnecessarily) stored in the db, when nothing changes?
> Hi Manuel,
> "entity per transaction config stuff"
> Which one is that?
configuration is called
"Instance Per Transaction CMP 2.x EntityBean" and doesn't work in conjunction with Commit-Option A.
it's good practice to declare methods of your entity-bean which do not change its state as readonly - therefore entity locks are holded only for the duration of the bean method invocation - not the entire tx.
your case seems kind of weired to me - normaly the cmp engine checks if any entity-bean fields have changed - so no unnecessary updates are promoted to the DB. Turn on cmp-tracing in log4.xml and look at the server.log if updates are really happening (package org.jboss.ejb.plugins.cmp).
yes after setting the tracing for the package
org.jboss.ejb.plugins.cmp I see thousends of calls to the ejbStore method. It is such slow that a transaction timeout occurs :)
I tried another locking policy (in standardjboss.xml)
Things remain the same. After each invocation of a findWhatever method, the beans are synchronized against the database.
There are no bussiness methods or other state-changing-methods in the bean except the setter methods, which are never called in the above scenario.
Another test: All Entity-Beans set to "readonly".
The store method is never called (I would wonder if it was so :)) but it's not what I'm looking for. There are few usecaces, where some of the entities are changed (monthly updates for example). I do not like to write two separate beans to access the table (readonly and an update-bean)
Is it necessary (or possible) to declare all getter-methods as readonly still beeing able to update the beans?
In my understanding of the container functionality, the container "installs" some kind of a proxy/wrapper object for each bean instanciated to "see" what happens to it. If a setter method is called, the bean becomes "dirty". In all other cases there is no need to synchronize.
Do you have a working configuration (standardjboss.xml) or an example that behaves as expected?
Perhaps, thanks again for your answer :)
I normally declare all getter methods on the entity beans component interface as "read-only".
However - I think what you see are a lot ejbStore calls in your entity beans, but no updates to the db. This is because of a known bug/shortcoming in the JDBCIsModifiedCommand in the cmp2 implementation. It is always returning true, which leads to unnecessary calls of ejbStore. But thank good it doesn't mean you get also unnecessary db updates, because the JDBCStoreManagers storeEntity()-method checks for modified fields and does NOT depend on JDBCIsModifiedCommand.
So I encourage you to check your logfiles for superflous SQL-Updates (maybe you can monitor this more effectivly with you db tools) - I am convinced there won't be any ;p
Hey, you are right :-)
There are no update statements for the tables on the sapdb trace log.
I know what my problem is. I couldn't belive it takes so much time to invoke the ejbStore method without writting anything to the table. All the validation stuff within the container is a real overkill for an application.
I think I have no other choices than to separate the readonly and write access. Maybe using one of the following patterns.
A.C.E. Smart Cache: http://www.theserverside.com/patterns/thread.jsp?thread_id=10610
Seppuku Pattern: http://www.theserverside.com/patterns/thread.jsp?thread_id=11280