/** * @param sessionFactory * @return */ @Bean @Autowired public HibernateTemplate hibernateTemplate(SessionFactory sessionFactory) { final HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory); hibernateTemplate.setCacheQueries(Boolean.TRUE); return hibernateTemplate; }
@SuppressWarnings("unchecked") @Transactional(readOnly = true) public <T extends Words> List<T> findAll(Class<T> wordsClass) { return (List<T>) template.find("FROM " + wordsClass.getSimpleName()); }
public <T extends Words> T persist(T words) { return template.merge(words); }
public Words update(Words words) { return template.merge(words); }
@Transactional(readOnly = true) public Words find(int id) { return template.get(Words.class, id); }