Created
April 11, 2013 23:45
-
-
Save rohman/5368141 to your computer and use it in GitHub Desktop.
Ulang Spring mvc Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package id.web.rohman.ulangspringservice.service.impl; | |
import id.web.rohman.ulangspringservice.model.Tamu; | |
import id.web.rohman.ulangspringservice.service.api.TamuService; | |
import java.util.List; | |
import org.hibernate.SessionFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Service; | |
import org.springframework.transaction.annotation.Transactional; | |
/** | |
* | |
* @author syahril | |
*/ | |
@Service("tamuService") @Transactional | |
public class TamuServiceImpl implements TamuService{ | |
@Autowired | |
private SessionFactory sessionFactory; | |
private void saveEntity(Object object) | |
{ | |
sessionFactory.getCurrentSession().saveOrUpdate(object); | |
} | |
public List<Tamu> listTamu() { | |
return sessionFactory.getCurrentSession().createCriteria(Tamu.class).list(); | |
} | |
public Tamu findTamuById(Integer id) { | |
return (Tamu) sessionFactory.getCurrentSession().get(Tamu.class, id); | |
} | |
public void saveTamu(Tamu tamu) { | |
this.saveEntity(tamu); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment