CMP is calling a stored proc which updates a field in table. When i do a findByPrimaryKey it returns me a state which is cached in container(before stored proc call), not the one in database updated by stored proc.
I am calling this cmp from session bean in jrun 3.1 on a sql server. How do i force the container to do a reload.
You should manually reload the data.
I came to a conclusion, that all entity EJBs must go. They cause more issues, that they solve.
The problem with stored procedures is one of them. Either you have to manually reload the data after stored procedure calls, or you have to ALWAYS reload the data. Both approaches are problematic.
The first one's issue is that the caller knows which bean calls stored procedures, and reloads data after that bean IF there are other beans accessing the same data. This means that bean's logic is not context-dependent, side effects etc. This messes up the design.
The second approach of ALWAYS reloading the data makes existence of entity EJBs senseless.
Another issue: suppose you want to calculate the total amount of something. You cannot do it effectively with Entity EJBs remote interfaces. So, you will call direct sql "select sum(amount) from ...". But then you have to save the data after every setXXX() method, if this call is made within the transaction with other entity EJB invocations.
Get rid of entity EJBs.