Named query not found exception

1,033 views
Skip to first unread message

Pyppe

unread,
Jan 19, 2011, 5:47:05 AM1/19/11
to play-framework
--- START CODE ---
@NamedQueries({
@NamedQuery(name="findExerciseTemplatesForUser", query =
"SELECT et FROM ExerciseTemplate et " +
"WHERE et.user.id = :userId " +
"ORDER BY et.name ASC")
})
public class UserDAO {
public static List<ExerciseTemplate> findExerciseTemplates(long
userId) {
Query query =
JPA.em().createNamedQuery("findExerciseTemplatesForUser");
query.setParameter("userId", userId);
return query.getResultList();
}
}
--- END CODE ---

Results in exception (UserDAO.java:23 is the line with
JPA.em().createNamedQuery):
--- START ERROR ---
play.exceptions.JavaExecutionException: Named query not found:
findExerciseTemplatesForUser
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:285)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.IllegalArgumentException: Named query not found:
findExerciseTemplatesForUser
at
org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:
451)
at dao.UserDAO.findExerciseTemplates(UserDAO.java:23)
--- END ERROR ---

Is this a bug? Am I doing something wrong? I'm using Play 1.1.

Guillaume Bort

unread,
Jan 19, 2011, 6:13:27 AM1/19/11
to play-fr...@googlegroups.com
I guess that @NamedQueries can only de declared on @Entity types.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Reply all
Reply to author
Forward
0 new messages