Regarding re-usability, is this OK? What might go wrong? What would be a better design? Performance-related issues and any other comments are welcome.
package sample.library.dao.util;
import java.io.Serializable;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Transactional;
/**
* @author mulean
*
*/
@Transactional(value = "transactionManager", timeout = 30,
rollbackFor = java.lang.Exception.class)
public class DAOUtil {
@Autowired
HibernateTemplate template;
public <T> T updateData(T t){
template.update(t);
return t;
}
public <T> T delete(T t){
template.delete(t);
return t;
}
public <T> Boolean save(T t){
boolean success = false;
try{
template.saveOrUpdate(t);
success = true;
}catch(Exception e){
success = false;
return success;
}
return success;
}
@SuppressWarnings("unchecked")
public <T> List<T> listData(String className){
List<T> items = null;
items = template.find("from "+className.toUpperCase());
return items;
}
}