Hibernate Map集合映射 - 全栈笔记

Hibernate Map集合映射

任亦伟 JAVA 2015-02-01 42 次浏览 没有评论

001
002
package com.renyiwei.wydns.domain;
003
 
004
import java.io.Serializable;
005
import java.util.Map;
006
 
007
public class Client implements Serializable {
008
 
009
	private static final long serialVersionUID = 4147291866512301737L;
010
	private Long id;
011
	private Byte iscompany;
012
	private String realname;
013
	private String companyname;
014
	private String email;
015
	private String phonenumber;
016
	private String notes;
017
	private Integer status = null;
018
 
019
	private Map<String, Map<String, String>> addon; //这个该怎么映射呢
020
 
021
	/**
022
	 * 实名认证状态 0:'未认证',1:'认证中',2:'认证成功',3:'认证失败'
023
	 */
024
	private Byte certifystatus = null;
025
 
026
 
027
	public Integer getStatus() {
028
		return status;
029
	}
030
 
031
	public void setStatus(Integer status) {
032
		this.status = status;
033
	}
034
 
035
	public Long getId() {
036
		return id;
037
	}
038
 
039
	public void setId(Long id) {
040
		this.id = id;
041
	}
042
 
043
	public Byte getIscompany() {
044
		return iscompany;
045
	}
046
 
047
	public void setIscompany(Byte iscompany) {
048
		this.iscompany = iscompany;
049
	}
050
 
051
	public String getRealname() {
052
		return realname;
053
	}
054
 
055
	public void setRealname(String realname) {
056
		this.realname = realname;
057
	}
058
 
059
	public String getCompanyname() {
060
		return companyname;
061
	}
062
 
063
	public void setCompanyname(String companyname) {
064
		this.companyname = companyname;
065
	}
066
 
067
	public String getEmail() {
068
		return email;
069
	}
070
 
071
	public void setEmail(String email) {
072
		this.email = email;
073
	}
074
 
075
	public String getPhonenumber() {
076
		return phonenumber;
077
	}
078
 
079
	public void setPhonenumber(String phonenumber) {
080
		this.phonenumber = phonenumber;
081
	}
082
 
083
 
084
	public String getNotes() {
085
		return notes;
086
	}
087
 
088
	public void setNotes(String notes) {
089
		this.notes = notes;
090
	}
091
 
092
	public Byte getCertifystatus() {
093
		return certifystatus;
094
	}
095
 
096
	public void setCertifystatus(Byte certifystatus) {
097
		this.certifystatus = certifystatus;
098
	}
099
 
100
	public Map<String, Map<String, String>> getAddon() {
101
		return addon;
102
	}
103
 
104
	public void setAddon(Map<String, Map<String, String>> addon) {
105
		this.addon = addon;
106
	}
107
}
108

映射文件:
01
02
<?xml version="1.0" encoding="utf-8"?>
03
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
04
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
05
<hibernate-mapping>
06
 
07
	<class name="com.renyiwei.wydns.domain.Client" table="clients">
08
 
09
		<id name="id" type="java.lang.Long" length="5">
10
			<column name="id" ></column>
11
			<generator class="increment"></generator>
12
		</id>
13
		<!-- 
14
			private Long id;
15
			private String email;
16
			private String phonenumber;
17
		 -->
18
		<property name="email" type="java.lang.String"></property>
19
		<property name="phonenumber" type="java.lang.String"></property>
20
		<map name="addon" table="clientaddons">
21
			<key column="clientid"></key>
22
			<map-key column="setting" type="java.lang.String"></map-key>   
23
			<!--这里待整理-->
24
			<one-to-many class="java.util.Map"></one-to-many>
25
		</map>
26
 
27
	</class>
28
</hibernate-mapping>
29

发表评论

回顶部