I have a method which is trying to use HQL to do a rather complex query within the database. My entity classes are all mapped with annotations and are discovered during compilation, not explicitly listed.
In the code which follows:
List<Message> ms = ((Session) entityManager.getDelegate())
.createCriteria(MessageCRI.class).list();
log.info("Got " + ms.size() + " CRIs");
List<Message> msgs = ((Session) entityManager.getDelegate())
.createQuery(
"from MessageCRI c where c.rfdId in (select id from MessageRFD rfd where rfd.ssrId = :ssrId)")
.setParameter("ssrId", ssrId).list();
The first call succeeds -- I get a message in the log stating "Got 2 CRIs" or somesuch. The very next call, however, fails, producing a stackdump with a root cause of "org.hibernate.hql.ast.QuerySyntaxException: MessageCRI is not mapped"
What could I be missing?