BaseService.java
资源名称:exams.rar [点击查看]
上传用户:nbxinmin
上传日期:2021-10-09
资源大小:46k
文件大小:1k
源码类别:
Internet/IE编程
开发平台:
Java
- package com.xdf.exams.bo.service;
- import org.hibernate.Session;
- import org.hibernate.Transaction;
- import com.xdf.exams.dao.hibernate.HibernateSessionFactory;
- public abstract class BaseService {
- public Session getSession() {
- return HibernateSessionFactory.getSession();
- }
- public void beginTransaction() {
- Transaction t = getSession().getTransaction();
- if(t!=null)
- t.begin();
- }
- public void commitTransaction() {
- Transaction t = getSession().getTransaction();
- if(t!=null)
- t.commit();
- }
- public void rollbackTransaction() {
- Transaction t = getSession().getTransaction();
- if(t!=null)
- t.rollback();
- }
- }