I had mentioned in a previous blog an issue I was seeing with my web application and its use of JPA. It turns out (thanks to people on the Glassfish users mailing list) that, after a refactoring, my JPQL query was rendered wrong up by using the name of the table instead of the name of the Java entity.
So
@NamedQueries(name = "Acctoken.findAll", query = "SELECT a FROM Acctoken a")
should have been:
@NamedQuery(name = "AccessToken.findAll", query = "SELECT a FROM AccessToken a")
Simple enough but, as I had written before, the fact that it somehow was working for subsequent calls remains a mystery to me…
June 12, 2009
Persistence API – Issue Resolved
Posted by Hubert under Computer science | Tags: Glassfish, Java, JPA, persistence |1 Comment
June 15, 2009 at 08:22
Two hypotheses:
– The fact that the application is working after the first query is due to a bug somewhere else. i.e the query isn’t working better, but since there is a short-cut somewhere, the application is working. It would be easy to infirm.
– After the first request, the JPA layer knows about the database meta-data. Specifically, it knows that there is a table named “Acctoken” and is able to guess that, since there are no Java entity, it should use this table instead.