我正在jsf
中开发一个Web应用程序我有这些课程
摘要:
类:
但是我在ManagedBeanCRUD上实现保存方法时遇到问题
在这个方法中我需要一个Repository,所以我有一个RepositoryBase rep = repositoryfactory.getFactory((entity.getClass()));
我试图以多种方式实现repositoryFactory,但仍然没有成功。
任何人都知道我怎么能这样做???
提前谢谢
public class ManagedBeanCRUD < T extends EntityBase> () {
protected T newEntity;
public void save() {
Repositoryfactory factory = new Repositoryfactory();
RepositoryBase<T> rep = factory.getFactory((entity.getClass()));
rep.persiste(newEntity);
}
}
public class FactoryRepository < T extends EntityBase> () {
public RepositoryBase<T> getFactory(Class newEntity) {
if(newEntity == Client.class) {
return new ClientRepository();
} else {
System.out.println("error");
}
}
}
public class ClientManagedBean extends CRUDBean<Client> {
private static final long serialVersionUID = 1L;
private Clietn client = new Client();
public void setSalve(){
this.setNewEntity(this.client);
this.salvar();
this.client = new Client();
}
}
公共类ClientRepository扩展了RepositoryBase {
@Override
protected Class<Client> getRuntimeClass() {
return Client.class;
}
}