Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30595

Re: Class<T> get generic type at runtime CDI

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Class<T> get generic type at runtime CDI
Date Fri, 19 Dec 2014 15:29:59 +0100
Lines 37
Message-ID <cfir38Fg52fU1@mid.individual.net> (permalink)
References <be034564-30a4-4be6-82fa-2dc7717b70c9@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net hRGwiyUCZ6y3JAlVMRykVQBIlND9fAeR3GSz2HSYZ1pNyKUI4=
Cancel-Lock sha1:Ij+4tIIeZQMjQl1Q4N/lDHDUBuA=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
In-Reply-To <be034564-30a4-4be6-82fa-2dc7717b70c9@googlegroups.com>
Xref csiph.com comp.lang.java.programmer:30595

Show key headers only | View raw


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


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