表結構
JavaBean檔案
package com.web.entity; import java.io.Serializable; public class User implements Serializable { private String uid; private String username; private String password; private String name; private String email; private Long telephone; private String birthday; private String sex; private Integer state; private Integer code; public String getUid() { return uid; } public void setUid(String uid) { this.uid = uid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public Long getTelephone() { return telephone; } public void setTelephone(Long telephone) { this.telephone = telephone; } public String getBirthday() { return birthday; } public void setBirthday(String birthday) { this.birthday = birthday; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public Integer getState() { return state; } public void setState(Integer state) { this.state = state; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } }XML檔案
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <!-- name屬性:當前組態檔對應的javaBean的全路徑 table屬性:當前組態檔對應的表 --> <class name="com.web.entity.User" table="user"> <!-- 標簽id:配置當前表主鍵的標簽 屬性name:javaBean所對應表中主鍵的屬性 屬性column:table中主鍵的欄位 --> <id name="uid" column="uid"> <!-- 標簽generator:配置主鍵的生成策略 當無此標簽時,hibernate不幫忙管理主鍵 屬性class:生成策略的型別 uuid:隨機字串 identity:主鍵自增 sequence:序列 increment:主鍵自增,單執行緒,maxID+1 hilo:主鍵自增,高低位演算法 native:hilo+identity+sequence三選一 guid:全球唯一識別符號 具體解釋看 轉載筆記 《Hibernate之主鍵生成策略》 --> <generator class="uuid"></generator> </id> <!-- 表簽property:普通屬性標簽 屬性name:javaBean對應屬性 屬性column:name中屬性對應的表欄位 --> <property name="username" column="username"></property> <property name="password" column="password"></property> <property name="name" column="name"></property> <property name="email" column="email"></property> <property name="telephone" column="telephone"></property> <property name="birthday" column="birthday"></property> <property name="sex" column="sex"></property> <property name="state" column="state"></property> <property name="code" column="code"></property> <!-- 還有其他特殊屬性配置見 筆記:《一對多配置》 --> </class> </hibernate-mapping>
表結構
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/226432.html
標籤:Java
下一篇:Linux 環境變數配置全攻略
