public class Test {
public static void main(String[] args) throws Exception
{
Generic<Customer> x = new Generic(Customer.class);
Customer cust = x.get("1");
System.out.println(cust.getFullname());
}
class Generic<T> {
private Class<T> clazz;
public Generic(Class<T> clazz) {
this.clazz = clazz;
}
public Session openSession() {
Configuration config = new AnnotationConfiguration().configure();
SessionFactory sf = config.buildSessionFactory();
Session session = sf.openSession();
return session;
}
public T get(String id) {
Session session = openSession();
T t = (T) session.get(clazz.getClass(), id);
return t;
}
}
When i run this program it dont except my Customer.class(Customer is just an entity class) and throw exception
org.hibernate.MappingException: Unknown entity: java.lang.Class.Please explain me why