> class Model<T> {
> public List<T> getAll() {
> // NameOfClass == T.class <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> return (List<T>) DB.getAll(NameOfClass.class);
> }
> }
> NameOfClass == T.class
> How can I get T.class from <T>??
You can't. It's prevented by type erasure. Here's what you do. You
modify the signature for the contructor to require a single parameter,
which is of type "Class<T>". There will be only one possible value for
that parameter, that being the Class object for the type T... so there's
no chance of someone passing in the wrong values, and you have the
necessary value which you can store in a field for later use.
Yes, it's kludgy. Yes, type erasure was a dumb idea. Nevertheless,
that's what you do.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
_v01 - 27 Dec 2005 23:06 GMT
Chris Smith napisał(a):
>>class Model<T> {
>> public List<T> getAll() {
[quoted text clipped - 15 lines]
> Yes, it's kludgy. Yes, type erasure was a dumb idea. Nevertheless,
> that's what you do.
Thank you for req.
There is solution:
http://www.hibernate.org/328.html