Hibernate e JPA 2.0 Fazendo LOCK em SELECTS. Por que?

Depois que eu fiz o upgrade do meu Hibernate para a versão 3.6, que utiliza o JPA 2.0 estou enfrentando um problema muito cabeludo.
Não sei pq diabos em várias SELECTS o dito cujo está fazendo LOCK das tabelas, e consequentemente as vezes travando minha aplicação.

Usei o comando no MYSQL “show full processlist” para saber todas as Querys ativas, e veja algumas que me apareceram.

[code]| Id | User | Host | db | Command | Time | State | Info

| 1607070 | db1614a1 | localhost:45378 | db1614 | Query | 8 | Locked | select userbean0_.user_id as user1_3_, userbean0_.is_active as is2_3_, userbean0_.branch_id as branch24_3_, userbean0_.charge_id as charge25_3_, userbean0_.contact_id as contact26_3_, userbean0_.day_of_birth as day3_3_, userbean0_.department_id as department27_3_, userbean0_.email as email3_, userbean0_.first_name as first5_3_, userbean0_.last_msg_notification as last6_3_, userbean0_.last_name as last7_3_, userbean0_.user_level as user8_3_, userbean0_.month_of_birth as month9_3_, userbean0_.news_read as news10_3_, userbean0_.has_oneyear_msg as has11_3_, userbean0_.password as password3_, userbean0_.has_photo as has13_3_, userbean0_.registration as registr14_3_, userbean0_.salted_hash as salted15_3_, userbean0_.search_engine as search16_3_, userbean0_.session_id as session17_3_, userbean0_.session_time as session18_3_, userbean0_.show_birth as show19_3_, userbean0_.unread_messages as unread20_3_, userbean0_.unread_pet as unread21_3_, userbean0_.username as username3_, userbean0_.year_of_birth as year23_3_ from webcollab_users userbean0_ where userbean0_.user_id=482 and userbean0_.session_id=‘4uhvi9e_482’ and userbean0_.is_active=1 limit 1 |

| 1607071 | db1614a1 | localhost:43349 | db1614 | Query | 8 | Locked | select userbean0_.user_id as user1_3_, userbean0_.is_active as is2_3_, userbean0_.branch_id as branch24_3_, userbean0_.charge_id as charge25_3_, userbean0_.contact_id as contact26_3_, userbean0_.day_of_birth as day3_3_, userbean0_.department_id as department27_3_, userbean0_.email as email3_, userbean0_.first_name as first5_3_, userbean0_.last_msg_notification as last6_3_, userbean0_.last_name as last7_3_, userbean0_.user_level as user8_3_, userbean0_.month_of_birth as month9_3_, userbean0_.news_read as news10_3_, userbean0_.has_oneyear_msg as has11_3_, userbean0_.password as password3_, userbean0_.has_photo as has13_3_, userbean0_.registration as registr14_3_, userbean0_.salted_hash as salted15_3_, userbean0_.search_engine as search16_3_, userbean0_.session_id as session17_3_, userbean0_.session_time as session18_3_, userbean0_.show_birth as show19_3_, userbean0_.unread_messages as unread20_3_, userbean0_.unread_pet as unread21_3_, userbean0_.username as username3_, userbean0_.year_of_birth as year23_3_ from webcollab_users userbean0_ where userbean0_.user_id=482 and userbean0_.session_id=‘4uhvi9e_482’ and userbean0_.is_active=1 limit 1 |

| 1607072 | db1614a1 | localhost:34160 | db1614 | Query | 7 | Locked | select userbean0_.user_id as user1_3_, userbean0_.is_active as is2_3_, userbean0_.branch_id as branch24_3_, userbean0_.charge_id as charge25_3_, userbean0_.contact_id as contact26_3_, userbean0_.day_of_birth as day3_3_, userbean0_.department_id as department27_3_, userbean0_.email as email3_, userbean0_.first_name as first5_3_, userbean0_.last_msg_notification as last6_3_, userbean0_.last_name as last7_3_, userbean0_.user_level as user8_3_, userbean0_.month_of_birth as month9_3_, userbean0_.news_read as news10_3_, userbean0_.has_oneyear_msg as has11_3_, userbean0_.password as password3_, userbean0_.has_photo as has13_3_, userbean0_.registration as registr14_3_, userbean0_.salted_hash as salted15_3_, userbean0_.search_engine as search16_3_, userbean0_.session_id as session17_3_, userbean0_.session_time as session18_3_, userbean0_.show_birth as show19_3_, userbean0_.unread_messages as unread20_3_, userbean0_.unread_pet as unread21_3_, userbean0_.username as username3_, userbean0_.year_of_birth as year23_3_ from webcollab_users userbean0_ where userbean0_.user_id=482 and userbean0_.session_id=‘4uhvi9e_482’ and userbean0_.is_active=1 limit 1 |

| 1607073 | db1614a1 | localhost:39199 | db1614 | Query | 5 | Locked | update webcollab_users set is_active=1, branch_id=1, charge_id=23, contact_id=271, day_of_birth=25, department_id=2, email=null, first_name=‘Higor’, last_msg_notification=0, last_name=‘Rodrigues Barreto’, user_level=10, month_of_birth=3, news_read=‘188’, has_oneyear_msg=0, password=‘4b295057b901295cc6ae911c27269b0a’, has_photo=1, registration=1258484938645, salted_hash=’’, search_engine=null, session_id=‘x2grkh9_449’, session_time=1295276056722, show_birth=1, unread_messages=0, unread_pet=0, username=‘higor’, year_of_birth=1986 where user_id=449 [/code]

Observe que em “State”, temos a informação “Locked”.
Para tentar contornar este problema, já fiz coisas como:

  • Definir o LockModeType para LockModeType.NONE em todas as operações de “EntityManager.find”
em.find(entityClass, primaryKey, LockModeType.NONE);
  • Definir o LockModeType para LockModeType.NONE na operação que executa exatamente as 03 primeiras queryes em estado Locked.
em.createNamedQuery(QUERY_NAME).setLockMode(LockModeType.NONE).getSingleResult();

Mas mesmo assim o problema continua a aparecer.
As querys NÃO ESTÃO entre “EntityTransaction.begin()” e “EntityTransaction.commit()”.
Alguem já enfrentou isso?

Como solucionar?