Hibernate中配置集合映射(1)
来源:互联网 发布:网络映射什么意思 编辑:程序博客网 时间:2024/06/06 09:06
Hibernate中配置集合映射
1.Set映射:
<set name="Set属性名" table="表名">
<key column="与主键关联字段名" />
<element type="数据类型" column="字段名" />
</set>
2.List映射:
<list name="List属性名" table="表名">
<key column="与主键关联字段名" />
<list-index column="索引字段名" />
<element type="数据类型" column="字段名" />
</list>
3.Map映射:
<map name="Map属性名" table="表名">
<key column="与主键关联字段名" />
<map-key type="数据类型" column="KEY字段名" />
<element type="数据类型" column="VALUE字段名" />
</map>
4.Array映射:
<array name="Array属性名" table="表名">
<key column="与主键关联字段名"/>
<list-index column="索引字段名" />
<element type="数据类型" column="字段名" />
</array>
hibernate.cfg.xml:
view plaincopy to clipboardprint?
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools.-->
<hibernate-configuration>
<session-factory>
<property name="connection.username">scott</property>
<property name="connection.url">
jdbc:oracle:thin:@127.0.0.1:1521:MGC
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="myeclipse.connection.profile">MGC</property>
<property name="connection.password">tiger</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="show_sql">true</property>
<mapping
resource="cn/edu/ahau/mgc/hibernate/pojo/Collection.hbm.xml" />
</session-factory>
</hibernate-configuration>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username">scott</property>
<property name="connection.url">
jdbc:oracle:thin:@127.0.0.1:1521:MGC
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="myeclipse.connection.profile">MGC</property>
<property name="connection.password">tiger</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="show_sql">true</property>
<mapping
resource="cn/edu/ahau/mgc/hibernate/pojo/Collection.hbm.xml" />
</session-factory>
</hibernate-configuration>
Collection.java:
view plaincopy to clipboardprint?
package cn.edu.ahau.mgc.hibernate.pojo;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Collection {
private long id;
private String name;
private Set setValues;
private List listValues;
private Map mapValues;
private String[] arrayValues;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set getSetValues() {
return setValues;
}
public void setSetValues(Set setValues) {
this.setValues = setValues;
}
public List getListValues() {
return listValues;
}
public void setListValues(List listValues) {
this.listValues = listValues;
}
public Map getMapValues() {
return mapValues;
}
public void setMapValues(Map mapValues) {
this.mapValues = mapValues;
}
public String[] getArrayValues() {
return arrayValues;
}
public void setArrayValues(String[] arrayValues) {
this.arrayValues = arrayValues;
}
}
package cn.edu.ahau.mgc.hibernate.pojo;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Collection {
private long id;
private String name;
private Set setValues;
private List listValues;
private Map mapValues;
private String[] arrayValues;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set getSetValues() {
return setValues;
}
public void setSetValues(Set setValues) {
this.setValues = setValues;
}
public List getListValues() {
return listValues;
}
public void setListValues(List listValues) {
this.listValues = listValues;
}
public Map getMapValues() {
return mapValues;
}
public void setMapValues(Map mapValues) {
this.mapValues = mapValues;
}
public String[] getArrayValues() {
return arrayValues;
}
public void setArrayValues(String[] arrayValues) {
this.arrayValues = arrayValues;
}
}
- Hibernate中配置集合映射(1)
- Hibernate中配置集合映射(2)
- Hibernate中配置集合映射(3)
- Hibernate中映射集合属性
- Hibernate的映射(集合)
- Hibernate映射集合属性1__Set集合
- Hibernate高级映射 --- 集合映射
- Hibernate高级映射 --- 集合映射
- Hibernate高级映射 --- 集合映射
- Hibernate高级映射 --- 集合映射
- Hibernate高级映射 --- 集合映射
- Hibernate高级映射 --- 集合映射
- Hibernate集合映射、关联映射
- hibernate中一对一映射配置详细解析(一)
- hibernate中一对一映射配置详细解析(二)
- hibernate中继承映射配置详细解析(一)
- hibernate中继承映射配置详细解析(二)
- hibernate中继承映射配置详细解析(三)
- c++
- 感动天,感动地
- first step
- 解决 PHP 加载 dll 模块出错的问题
- 09即将流行的经典语录!
- Hibernate中配置集合映射(1)
- Hibernate中配置集合映射(2)
- Hibernate中配置集合映射(3)
- 老师,Windows Vista下怎么配置JDK的环境变量?
- 关于母版页面
- 寻求帮助
- 困惑
- 原来还不是太坏
- 记录下每天进步的短文