I've got the following problem on Hibernate 3.5.6 with EHcache 2.5.0: I have this named query:
@NamedQuery(name = "User.findUserRolesByUserName", query = "select distinct u.roles from User u where u.numeUtilizator = :userName", hints = {@QueryHint(name="org.hibernate.cacheable", value="true") })
When it executes the first time the query.list() method the results are ok (coming from the database) but when subsequently it takes them from the cache, the list has null values. I looked into Hibernate code and i found that when it calls QueryLoader.list(SessionImplementor, QueryParameters, Set, Type[]) it passes a Type[] that contains one entry of type SetType. Further on, at StandardQueryCache.put(), the result parameter is correct - it contains a list of elements of type Rol (the expected type of the query results) - but still the Type[] parameter containing a SetType, when it gets to the cacheable.add( returnTypes[0].disassemble( result.get( i ), session, null ) ); line, it calls the CollectionType (parent class) disassemble() method that returns null because the third parameter is null.
The Rol entity is annotated as follows: @Entity @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Table(name = "USR_ROLURI")
Could someone please tell me what is the problem? Many thanks, Simon
|