Cameron Wallace McKenzie wrote:What did you try that didn't work? What was the error that was generated?
-Cameron McKenzie
Rajesh Kottayil wrote:
Hello friends,
I am facing bottle neck with Object Locking for an Entity bean using OpenJPA Persistence Manager under Weblogic 10.0 application server deployments.
I want to block [ for the specific method ] entity bean being accessed from other client programs when they invoke common method in a Stateless Session EJB. Particularly, Consider the situation:
Client1: Modifying Customer entity with id: 100. Then I locked that entity using OpenJPA Entity Manager within the transaction block. And i entered that thread to sleep before committing the transaction.
At this time, started new thread, Client2: Modifying the same Customer entity with id:100. I expected this thread will be get blocked when control pass to the lock() method. But it doesn't happened. It goes through the line of codes and also put into sleep.
After thread sleep timeout, first thread Client1 commit successfully. But the second gets Rollback Exception due to optimistic lock exception occurring since customer entity is modified in another transaction.
This exception is occurred because of Database level concurrency control for optimistic locking in a weblogic server. Its default to weblogic.
But, what i expected is to assert lock at the object level, thereby the 2nd thread - Client2 will be blocked while Client1 is in the middle of a transaction and then Client2 use modified Customer entity . But it doesn't happened. I used Kodo Persistance Provider as Persistence Unit, OpenJPAEntityManager to do transaction, locking , finding and merging the entity bean.
Can anyone provide help to fine grain this object locking functionality ??? I look forward to your brilliant thoughts......
Rajesh KR
Geojit Technologies
brajen mathema wrote:hi,
i have injected the persistence context in my session bean as:
@PersistenceContext(unitName = "Project-PU")
private EntityManager em;
my glassfish setting under resource is as follows
General Settings
Name: mssql/db_mssql
Datasource Classname: com.microsoft.sqlserver.jdbc.SQLServerXADataSource
Resource Type: javax.sqlXADataSource
Pool Settings
Initial and Minimum Pool Size: 10 Connections
Maximum Pool Size: 100 Connections
Pool Resize Quantity: 5 Connections
Idle Timeout: 300 Seconds
Max Wait Time: 60000 Milliseconds
Connection Validation
Connection Validation: not checked(i.e disabled)
Validation Method: auto-commit(selected value)
Table Name: not selected
On Any Failure: not checked
Allow Non Component Callers: not checked
Transaction
Non Transactional Connections: Enabled
Transaction Isolation:not selected
Isolation Level: not selected
in advance tab : default values are used
so what's the problem...
any idea....
what else are the required setting for CMT in glassfish or stateless ejb class
thanks..
-brajen