Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30595
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Class<T> get generic type at runtime CDI |
| Date | 2014-12-19 15:29 +0100 |
| Message-ID | <cfir38Fg52fU1@mid.individual.net> (permalink) |
| References | <be034564-30a4-4be6-82fa-2dc7717b70c9@googlegroups.com> |
On 19.12.2014 13:23, Leonan Luppi wrote:
> Hello,
>
> I'm try to get generic class type but isn't work. Someone can help
> me? I'm using CDI Weld to Inject my DAO class with a generic type:
>
>
> @Inject
> private DAO<Agent> dao;
>
> And my DAO Class:
>
> public class DAO<T> {
>
> public T findAll() {
> CriteriaQuery<T> query = em.getCriteriaBuilder()
> .createQuery(HERE_MY_GENERIC_CLASS);
> query.select(query.from(HERE_MY_GENERIC_CLASS));
> return (T) em.createQuery(query).getResultList();
> }
>
> }
>
>
> How can i get at runtime? To make a query.
Judging from the code you presented you need at least to return a
collection of T (e.g. Iterable<T>) and not a T.
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Class<T> get generic type at runtime CDI Leonan Luppi <leonan.luppi@gmail.com> - 2014-12-19 04:23 -0800
Re: Class<T> get generic type at runtime CDI Robert Klemme <shortcutter@googlemail.com> - 2014-12-19 15:29 +0100
Re: Class<T> get generic type at runtime CDI Leonan Luppi <leonan.luppi@gmail.com> - 2014-12-19 07:13 -0800
Re: Class<T> get generic type at runtime CDI Sebastian <news@seyweiler.dyndns.org> - 2014-12-20 15:20 +0100
Re: Class<T> get generic type at runtime CDI Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-12-20 18:28 +0000
csiph-web