为什么会报这个错误?是什么意思
这是hql查询语句
select distinct f,iv from InventoryFlight iv,Flight f where iv.productId=f.id order by iv.useDate asc
inventoryFlight里有flight的id
...全文
3292打赏收藏
possible non-threadsafe access to the session
为什么会报这个错误?是什么意思 这是hql查询语句 select distinct f,iv from InventoryFlight iv,Flight f where iv.productId=f.id order by iv.useDate asc inventoryFlight里有flight的id
By stepping through the hibernate source code, I found out that the cause of the "possible nonthreadsafe access to session" error is that an AssetEntry instance is not found in the hibernate session context during a session flush, more specifically while an insert operation is being processed. What that means is that, under certain conditions, an AssetEntry object is inserted into the hibernate session context, then evicted later on before the session is flushed. Finally, when the session is flushed and the insert event is being processed, the AssetEntry object is no longer in the session context.
From what I see, this is not an easily reproduceable problem due to the many factors involved, including:
1. The fact that BATCH mode is enabled for layout imports (see LayoutLocalServiceImpl.importLayouts())
2. When an entity that was retrieved from cache gets deleted, and we are in batch mode, the entity gets evicted immediately from the hibernate session (see BatchSessionImpl.delete())
3. When the JDBC batch limit is reached (default 20), the session gets flushed.
4. An AssetEntry is deleted every time an DLFileEntry workflow status is updated (the "draft" version).
Like I said earlier, I have not yet identified the exact conditions that lead to the AssetEntry being evicted from the hibernate session too soon, but I wanted to share what I found and maybe someone else can shed more light on the problem. I will continue looking into it and update when I have more info.