Sorry for writing post with such screaming subject, but at least for me it's very important problem.
I want to rise the same problem again, please read the first orginal thread also:
I thought that I solved temporrary the problem described in original thread with such trick:
if select count(*) return for example 2
but select f returns only 1 object. I execute again select with additional condition " and 1192011323161 = 1192011323161" (These numbers are just current time in milisecs). My goal was to show that select is new and unique and I thought that in such case jboss will execute this query and would not use its own cache. For a while I thought that this is working, but now sometimes when this bug occurs and I execute again query with additional condintion i getting correct count of objects for example 2, but in results List I getting the same object twice, not two different objects how schould be.
Also I noticed that if in persistence.xml set such values to false, maybe bug occurs not so often but for sure it occurs.
<property name="hibernate.cache.use_second_level_cache" value="false"/> <property name="hibernate.cache.use_query_cache" value="false" /> <property name="hibernate.statement_cache.size" value="0"/>