Hi Kyle,

It looks like `namedQuery` is a wrapper for 
`getSession().getNamedQuery(queryName)`. `Session` also has a 
`createNamedQuery` method, which will return a `Query<E>` that is 
compatible with `list`:

```
public List<Person> findAll() {
  return 
list(getSession().createNamedQuery("com.example.helloworld.core.Person.findAll",
 
getEntityClass()));
}
```

Since `list` is itself a small wrapper around `Query.list`, you could also 
avoid dw's wrapper entirely and rewrite this as:

```
public List<Person> findAll() {
  return 
getSession().createNamedQuery("com.example.helloworld.core.Person.findAll", 
getEntityClass()).list();
}
```

Hope that helps!

On Tuesday, May 2, 2017 at 8:52:17 PM UTC-4, Kyle K wrote:
>
> In the example application there is a PersonDAO class with a findAll() 
> method:
>
>
> https://github.com/dropwizard/dropwizard/blob/release/1.1.x/dropwizard-example/src/main/java/com/example/helloworld/db/PersonDAO.java
>
> public List<Person> findAll() {
>     return list(namedQuery("com.example.helloworld.core.Person.findAll"));
> }
>
> This calls namedQuery() which returns a non-generic Query, however list() 
> has no version which accepts that; only Criteria, CriteriaQuery<E>, and 
> Query<E>:
>
>
> http://www.dropwizard.io/1.1.0/dropwizard-hibernate/apidocs/io/dropwizard/hibernate/AbstractDAO.html
>
>
> Is there a known workaround to use named queries with the AbstractDAO 
> list() functions in 1.1.0?
>

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to