Liu*_*x31 5 java spring hibernate
我正在学习有关 Hibernate 的教程并看到以下代码:
package com.websystique.spring.dao;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class AbstractDao {
@Autowired
private SessionFactory sessionFactory;
protected Session getSession() {
return sessionFactory.getCurrentSession();
}
public void persist(Object entity) {
getSession().persist(entity);
}
public void delete(Object entity) {
getSession().delete(entity);
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道persist()(或save()或delete())是否可以在没有事务的情况下使用?就像这里的情况一样。
| 归档时间: |
|
| 查看次数: |
5645 次 |
| 最近记录: |