Hibernate集合映射学习
来源:互联网 发布:为什么要使用数组 编辑:程序博客网 时间:2024/06/05 17:36
测试类:
public class CollectionMapping {private int id;private String cname;private String[] arrayValue;private List listValue;private Set SetValue;private Map mapValue;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getCname() {return cname;}public void setCname(String cname) {this.cname = cname;}public String[] getArrayValue() {return arrayValue;}public void setArrayValue(String[] arrayValue) {this.arrayValue = arrayValue;}public List getListValue() {return listValue;}public void setListValue(List listValue) {this.listValue = listValue;}public Set getSetValue() {return SetValue;}public void setSetValue(Set setValue) {SetValue = setValue;}public Map getMapValue() {return mapValue;}public void setMapValue(Map mapValue) {this.mapValue = mapValue;}public static void main(String[] args) {Configuration cfg = new Configuration().configure();SchemaExport export = new SchemaExport(cfg);export.create(true, true);HibernateTemplate.execute(new SessionOperate(){@Overridepublic void doSession(Session session) {// TODO Auto-generated method stubCollectionMapping collectionMapping = new CollectionMapping();collectionMapping.setCname("c");String[] array = {"liu","li"};collectionMapping.setArrayValue(array);List list = new ArrayList();list.add("l1");list.add("l2");collectionMapping.setListValue(list);Set set = new HashSet();set.add("s1");set.add("s2");collectionMapping.setSetValue(set);Map map = new HashMap();map.put("k1", "v1");map.put("k2", "v2");collectionMapping.setMapValue(map);session.save(collectionMapping);}});}}
配置文件:
<hibernate-mapping package="com.pk.po"><class name="CollectionMapping" table="tb_col_mapping"><id name="id"><generator class="native"></generator></id><property name="cname"></property><array name="arrayValue" table="t_array"><key column="arrayId"></key><list-index column="arrayIndex"></list-index><element column="arrayValue" type="string"></element></array><list name="listValue" table="t_list"><key column="listId"></key><list-index column="listIndex"></list-index><element column="listValue" type="string"></element></list><set name="SetValue" table="t_set"><key column="setId"></key><element column="setValue" type="string" ></element></set><map name="mapValue" table="t_map"><key column="mapId"></key><map-key column="mapKey" type="string"></map-key><element column="mapValue" type="string"></element></map></class></hibernate-mapping>
由于简化,便直接在po中测试了
复制搜索
复制搜索
- Hibernate集合映射学习
- Hibernate学习_015_集合映射
- hibernate集合映射学习笔记
- 【HIbernate框架学习】:Hibernate集合映射
- Hibernate 3.2 学习笔记 映射集合类
- Hibernate学习文档_集合映射
- 【Hibernate学习笔记】映射值类型集合
- Hibernate学习笔记:集合映射之映射Map
- Hibernate学习笔记:集合映射之映射List
- Hibernate学习笔记:集合映射之映射Set, Bag
- Hibernate学习22 -- 关联映射12 -- 集合映射
- Hibernate学习笔记:集合映射之映射Map
- Hibernate学习笔记(七)----集合映射、继承映射、作业
- Hibernate 学习笔记07 --集合映射_&_继承映射
- Hibernate学习笔记1— Hibernate中的集合映射
- Hibernate高级映射 --- 集合映射
- Hibernate高级映射 --- 集合映射
- Hibernate高级映射 --- 集合映射
- FileWriter类在进行文件的读写时可以自动创建文件
- 批处理文件和ORACLE的功能
- 2011年 下半年 C++程序设计 (三十)
- 四极管:Uboot运行分析(二)
- 十四周实验报告2:学会使用循环控制语句解决实际问题
- Hibernate集合映射学习
- c++中全局的 const 使用问题
- “Microsoft Office Word已停止工作”的终极解决方案 (转)
- 十五周实验报告1:学会冒泡排序算法
- 修改名字(表名,列明等)
- mysql模式:master/slave
- HDU 1161(Eddy's mistakes )
- Follow with your heart 跟随心灵的引导
- VMware虚拟机配置Ubuntu上网——Bridged方式