原创  Summary on 20080707: Hibernate operation on many-to-one relation 收藏

Hibernate many-to-one relation mapping:

public class Student{

    .....

    private CoreClass class;



    public CoreClass getter....

    public void setter

}





public class CoreClass{

....

}

<many-to-one name="class" column="classId" class="CoreClass" not-null="" cascade=""/>

Note

1. for the attribute not-null, if set to 'true', before insert data to database, hibernate will check, if class is null, throw exception before insert data

2. cascasde: mostly, the value should be 'save-update', should not be any value related to 'delete'

3. the order of insert one instance of class to database( class has already been assigned with vlaue) 3.1 insert class instance to db(if there is any mapping setting for CoreClass, it will done first) 3.2 insert student instance to db

发表于 @ 2008年07月07日 23:57:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:Summary on 20080706: setting for many-to-many mapping in hibernate | 新一篇:Summary on 20080710: union and projection search by QBC

  • 发表评论
  • 评论内容:
  •  
Copyright © crazy_coder
Powered by CSDN Blog