[weld-commits] Weld SVN: r6887 - archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Tue Aug 3 18:31:38 EDT 2010
Author: dan.j.allen
Date: 2010-08-03 18:31:37 -0400 (Tue, 03 Aug 2010)
New Revision: 6887
Modified:
archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberResourceRESTService.java
Log:
make recommendation about using @NamedQuery references
Modified: archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberResourceRESTService.java
===================================================================
--- archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberResourceRESTService.java 2010-08-03 22:31:16 UTC (rev 6886)
+++ archetypes/javaee6-webapp/trunk/src/main/java/com/mycompany/MemberResourceRESTService.java 2010-08-03 22:31:37 UTC (rev 6887)
@@ -16,7 +16,6 @@
@RequestScoped
public class MemberResourceRESTService
{
- private static final String ALL_MEMBERS = "select m from Member m order by m.name";
@Inject
@MemberRepository
private EntityManager em;
@@ -24,8 +23,11 @@
@GET
public List<Member> listAllMembers()
{
- @SuppressWarnings("unchecked") // Force IDE to ignore warnings about "genericizing" the results of this query
- final List<Member> results = em.createQuery(ALL_MEMBERS).getResultList();
+ // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of this query
+ @SuppressWarnings("unchecked")
+ // We recommend centralizing inline queries such as this one into @NamedQuery annotations on the @Entity class
+ // as described in the named query blueprint: https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html
+ final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList();
return results;
}
More information about the weld-commits
mailing list