Hi, I'm fairly new to Java Entities, and I've got a bit of a strange problem casting from a Query.getSingleResult() call. Here's a code snippet:
LoaPoliciesConfig policy = new LoaPoliciesConfig();
EntityManager em = getEntityManager();
try
{
Query q = em.createNamedQuery("LoaPoliciesConfig.findByName");
q.setParameter("policyName", policyName);
Object ret = q.getSingleResult();
policy = (LoaPoliciesConfig) ret;
}
After working fine for ages, this has suddenly started giving me this error:
CRAAC.WebService.DataAccess.LoaPoliciesConfig cannot be cast to
CRAAC.WebService.DataAccess.LoaPoliciesConfig
At first this went away when restarting the server, but the last time it happens it seems to be here to stay.
getSingleQuery() returns an Object, and all the documentation I've found on the web so far seem to indicate this is the preferred way of doing it. So, my question is essentially am I do anything wrong in this code, or is it just the server getting confused somewhere along the way?