hibernate级联情况下以commit或者flush来进行级联提交
来源:互联网 发布:软件人力外派 编辑:程序博客网 时间:2024/05/17 04:51
1.2.3. 使关联工作
Now we will bring some people and events together in a new method in EventManager
:
private void addPersonToEvent(Long personId, Long eventId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Person aPerson = (Person) session.load(Person.class, personId); Event anEvent = (Event) session.load(Event.class, eventId); aPerson.getEvents().add(anEvent); session.getTransaction().commit(); }
After loading a Person
and an Event
, simply modify the collection using the normal collection methods. There is no explicit call to update()
or save()
; Hibernate automatically detects that the collection has been modified and needs to be updated. This is called automatic dirty checking. You can also try it by modifying the name or the date property of any of your objects. As long as they are in persistent state, that is, bound to a particular Hibernate org.hibernate.Session
, Hibernate monitors any changes and executes SQL in a write-behind fashion. The process of synchronizing the memory state with the database, usually only at the end of a unit of work, is called flushing. In our code, the unit of work ends with a commit, or rollback, of the database transaction.
- hibernate级联情况下以commit或者flush来进行级联提交
- hibernate级联
- hibernate级联
- hibernate级联
- Hibernate级联
- 删除级联hibernate级联删除
- Hibernate session flush commit
- hibernate commit和flush
- hibernate flush与commit
- HIbernate commit() and flush()
- hibernate中双向关联在级联情况下save对象讨论
- Hibernate 下实现数据的级联插入
- 级联
- 级联
- 级联
- SQLite 级联删除或者级联更新无效
- hibernate一对多以非主外键字段做级联
- hibernate的级联----cascade
- openCV的配置
- SQLite简介
- Xcode真机测试could not find developer disk image解决方法
- Swift-Realm简单使用,代替Sqlite、Crodata的强大数据库
- memcache(三)应用场景,session存入memcache
- hibernate级联情况下以commit或者flush来进行级联提交
- DB2中的数据加密
- 最大熵的Java实现
- weblogic 设置多少个GC线程合适
- 解决eclipse中MAVEN项目提示One or more constraints have not been satisfied
- Ansible UI web 界面搭建 ----欢迎大家一起讨论研究
- ST算法(Sparse-Table)
- Android之eclipse 新版NDK环境搭建(免Cygwin,超级快)-可用
- max函数