Can a named finder be used for reload of an entity evicted from level 2 cache in EAP 6?
Issue
- An entity has been modeled that can only be loaded using a stored procedure and a named query is used to invoke the procedure
@NamedNativeQuery(name="MyEntity.loadProcedure",query="{call test.dbo.loadMyEntity(:theId)}",
hints={
@QueryHint(name="org.hibernate.callable", value="true"),
@QueryHint(name="org.hibernate.cacheable", value="true")
}, resultClass=MyEntity.class
)
- An HQL query executed by user code after eviction of an entity from the level 2 Hibernate cache fails during load of the entity data
2014-06-25 15:01:43,039 INFO ... Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [MyEntity#720701]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2086)
...
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:116)
at test.CachedMyEntityBean.getData(CachedMyEntityBean.java:65)
...
Caused by: java.sql.SQLException: MyEntity not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)
...
at com.sybase.jdbc4.jdbc.SybPreparedStatement.executeQuery(Unknown Source)
...
at org.hibernate.loader.Loader.loadEntity(Loader.java:2072)
...
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6
- Hibernate 4
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
