hi all we create an example using Struts2-Spring-Hibernate, using Spring way, DAO-Services
this is the SVN http://ugforge.gunadarma.ac.id/svn/cimande/branches/rest-struts the project run perfectly but we use this package for @Services and @Transactional import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; my idea to remove all depedency with Spring any idea to replace this code? this is the full code /** * PersonServiceImpl.java * * Created on 01 Agu 2010 13:07:24 */ package org.blueoxygen.cimande.example.geneology.service; import java.sql.Timestamp; import java.util.List; import org.blueoxygen.cimande.example.geneology.Person; import org.blueoxygen.cimande.example.geneology.dao.PersonDAO; import org.blueoxygen.cimande.security.SessionCredentials; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /** * @author Dian Aditya * */ @Service @Transactional(readOnly = true) public class PersonServiceImpl implements PersonService { @Autowired private PersonDAO personDao; @Autowired private SessionCredentials credentials; @Transactional public void save(Person person) { if (credentials.getCurrentUser() != null) { person.getLogInformation().setLastUpdateBy( credentials.getCurrentUser().getId()); person.getLogInformation().setLastUpdateDate( new Timestamp(System.currentTimeMillis())); person.getLogInformation().setCreateBy( credentials.getCurrentUser().getId()); person.getLogInformation().setCreateDate( new Timestamp(System.currentTimeMillis())); } personDao.persist(person); } @Transactional public void update(Person person) { Person temp = personDao.getById(Person.class, person.getId()); if (temp != null) { if (credentials.getCurrentUser() != null) { person.getLogInformation().setLastUpdateBy( credentials.getCurrentUser().getId()); person.getLogInformation().setLastUpdateDate( new Timestamp(System.currentTimeMillis())); } personDao.merge(person); } } @Transactional public void delete(Person person) { Person temp = personDao.getById(Person.class, person.getId()); if (temp != null) { List<Person> childs = personDao.getChilds(temp); if (temp.isMale()) { for (Person c : childs) { c.setFather(null); personDao.persist(c); } } else { for (Person c : childs) { c.setMother(null); personDao.persist(c); } } personDao.remove(temp); } } @Transactional(readOnly = true) public List<Person> getPersons() { return personDao.findAll(Person.class); } @Transactional(readOnly = true) public List<Person> getPersons(String field, String contain) { return personDao.find(Person.class, field, contain); } @Transactional(readOnly = true) public Person getPerson(String id) { return personDao.getById(Person.class, id); } @Transactional(readOnly = true) public List<Person> getChilds(Person parent) { return personDao.getChilds(parent); } @Transactional(readOnly = true) public List<Person> getChildsList(Person parent) { return personDao.getCildsList(parent); } }