|
From: Achmad A. R. <a.a...@gm...> - 2005-10-11 04:33:58
|
How to read Inherit Generic Type class ?
Guys I've been googling all week but couldn't find solution.
Id like to create Generic DAO pattern. So here's what i do
public interface Dao<E extends Entity, I extends Serializable>{
public I create(E entity);
public E read(I id);
public void update(E entity);
public E delete(I id);
}
concrete class would be like this
public class DaoBean implements Dao{
public Serializable create(Entity entity){
getHibernateTemplate.save(entity);
return entity.getId();
}
public void update(Entity entity){
getHibernateTemplate.update(entity);
}
public Entity read(Serializable id){
return (Entity)getHibernateTemplate.load(getClass(),id);
}
public Entity delete(Serializable id){
Entity entity =3D read(id);
getHibernateTemplate.delete(entity);
return entity;
}
public Class getEntityClass(){
// now ... how to get Dao E class ????
return E.class;
}
}
The millon dollar* question is how to get Dao Generic E type class ???
(* million asked question)
Thanx
|