011 Hibernate反向工程构建实体和hbm文件 - bos

package com.hao.bos.entity;
// Generated 2017-8-15 16:30:28 by Hibernate Tools 4.0.0

import java.util.HashSet;
import java.util.Set;

/**
* 定区
*/
public class Decidedzone implements java.io.Serializable {

private static final long serialVersionUID = 1L;

private String id;
private Staff staff;
private String name;
private Set<Subarea> subareas = new HashSet<Subarea>(0);

public Decidedzone() {
}

public Decidedzone(String id) {
this.id = id;
}

public Decidedzone(String id, Staff staff, String name,
Set<Subarea> subareas) {
this.id = id;
this.staff = staff;
this.name = name;
this.subareas = subareas;
}

public String getId() {
return this.id;
}

public void setId(String id) {
this.id = id;
}

public Staff getStaff() {
return this.staff;
}

public void setStaff(Staff staff) {
this.staff = staff;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public Set<Subarea> getSubareas() {
return this.subareas;
}

public void setSubareas(Set<Subarea> subareas) {
this.subareas = subareas;
}

}

package com.hao.bos.entity;

import java.util.HashSet;
import java.util.Set;

/**
* 区域
*/
public class Region implements java.io.Serializable {

private static final long serialVersionUID = 1L;

private String id;
private String province;
private String city;
private String district;
private String postcode;
private String shortcode;
private String citycode;
private Set<Subarea> subareas = new HashSet<Subarea>(0);

public Region() {
}

public Region(String id) {
this.id = id;
}

public Region(String id, String province, String city, String district,
String postcode, String shortcode, String citycode,
Set<Subarea> subareas) {
this.id = id;
this.province = province;
this.city = city;
this.district = district;
this.postcode = postcode;
this.shortcode = shortcode;
this.citycode = citycode;
this.subareas = subareas;
}

public String getId() {
return this.id;
}

public void setId(String id) {
this.id = id;
}

public String getProvince() {
return this.province;
}

public void setProvince(String province) {
this.province = province;
}

public String getCity() {
return this.city;
}

public void setCity(String city) {
this.city = city;
}

public String getDistrict() {
return this.district;
}

public void setDistrict(String district) {
this.district = district;
}

public String getPostcode() {
return this.postcode;
}

public void setPostcode(String postcode) {
this.postcode = postcode;
}

public String getShortcode() {
return this.shortcode;
}

public void setShortcode(String shortcode) {
this.shortcode = shortcode;
}

public String getCitycode() {
return this.citycode;
}

public void setCitycode(String citycode) {
this.citycode = citycode;
}

public Set<Subarea> getSubareas() {
return this.subareas;
}

public void setSubareas(Set<Subarea> subareas) {
this.subareas = subareas;
}

}

package com.hao.bos.entity;

import java.util.HashSet;
import java.util.Set;

/**
* 取派员
*/
public class Staff implements java.io.Serializable {

private static final long serialVersionUID = 1L;

private String id;
private String name;
private String telephone;
private Character haspda;
private Character deltag;
private String station;
private String standard;
private Set<Decidedzone> decidedzones = new HashSet<Decidedzone>(0);

public Staff() {
}

public Staff(String id) {
this.id = id;
}

public Staff(String id, String name, String telephone, Character haspda,
Character deltag, String station, String standard,
Set<Decidedzone> decidedzones) {
this.id = id;
this.name = name;
this.telephone = telephone;
this.haspda = haspda;
this.deltag = deltag;
this.station = station;
this.standard = standard;
this.decidedzones = decidedzones;
}

public String getId() {
return this.id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getTelephone() {
return this.telephone;
}

public void setTelephone(String telephone) {
this.telephone = telephone;
}

public Character getHaspda() {
return this.haspda;
}

public void setHaspda(Character haspda) {
this.haspda = haspda;
}

public Character getDeltag() {
return this.deltag;
}

public void setDeltag(Character deltag) {
this.deltag = deltag;
}

public String getStation() {
return this.station;
}

public void setStation(String station) {
this.station = station;
}

public String getStandard() {
return this.standard;
}

public void setStandard(String standard) {
this.standard = standard;
}

public Set<Decidedzone> getDecidedzones() {
return this.decidedzones;
}

public void setDecidedzones(Set<Decidedzone> decidedzones) {
this.decidedzones = decidedzones;
}

}

package com.hao.bos.entity;

/**
* 分区
*/
public class Subarea implements java.io.Serializable {

private static final long serialVersionUID = 1L;

private String id;
private Decidedzone decidedzone; //定区
private Region region; //区域
private String addresskey;
private String startnum;
private String endnum;
private Character single;
private String position;

public Subarea() {
}

public Subarea(String id) {
this.id = id;
}

public Subarea(String id, Decidedzone decidedzone, Region region,
String addresskey, String startnum, String endnum,
Character single, String position) {
this.id = id;
this.decidedzone = decidedzone;
this.region = region;
this.addresskey = addresskey;
this.startnum = startnum;
this.endnum = endnum;
this.single = single;
this.position = position;
}

public String getId() {
return this.id;
}

public void setId(String id) {
this.id = id;
}

public Decidedzone getDecidedzone() {
return this.decidedzone;
}

public void setDecidedzone(Decidedzone decidedzone) {
this.decidedzone = decidedzone;
}

public Region getRegion() {
return this.region;
}

public void setRegion(Region region) {
this.region = region;
}

public String getAddresskey() {
return this.addresskey;
}

public void setAddresskey(String addresskey) {
this.addresskey = addresskey;
}

public String getStartnum() {
return this.startnum;
}

public void setStartnum(String startnum) {
this.startnum = startnum;
}

public String getEndnum() {
return this.endnum;
}

public void setEndnum(String endnum) {
this.endnum = endnum;
}

public Character getSingle() {
return this.single;
}

public void setSingle(Character single) {
this.single = single;
}

public String getPosition() {
return this.position;
}

public void setPosition(String position) {
this.position = position;
}

}

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-8-15 16:30:28 by Hibernate Tools 4.0.0 -->
<hibernate-mapping>
<class name="com.hao.bos.entity.Decidedzone" table="bc_decidedzone">
<id name="id" type="string">
<column name="id" length="32" />
<generator class="assigned" />
</id>
<many-to-one name="staff" class="Staff" fetch="select">
<column name="staff_id" length="32" />
</many-to-one>
<property name="name" type="string">
<column name="name" length="30" />
</property>
<set name="subareas" table="bc_subarea" inverse="true" lazy="true" fetch="select">
<key>
<column name="decidedzone_id" length="32" />
</key>
<one-to-many class="Subarea" />
</set>
</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-8-15 16:30:28 by Hibernate Tools 4.0.0 -->
<hibernate-mapping>
<class name="com.hao.bos.entity.Region" table="bc_region" >
<id name="id" type="string">
<column name="id" length="32" />
<generator class="assigned" />
</id>
<property name="province" type="string">
<column name="province" length="50" />
</property>
<property name="city" type="string">
<column name="city" length="50" />
</property>
<property name="district" type="string">
<column name="district" length="50" />
</property>
<property name="postcode" type="string">
<column name="postcode" length="50" />
</property>
<property name="shortcode" type="string">
<column name="shortcode" length="30" />
</property>
<property name="citycode" type="string">
<column name="citycode" length="30" />
</property>
<set name="subareas" table="bc_subarea" inverse="true" lazy="true" fetch="select">
<key>
<column name="region_id" length="32" />
</key>
<one-to-many class="Subarea" />
</set>
</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-8-15 16:30:28 by Hibernate Tools 4.0.0 -->
<hibernate-mapping>
<class name="com.hao.bos.entity.Staff" table="bc_staff" >
<id name="id" type="string">
<column name="id" length="32" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="name" length="20" />
</property>
<property name="telephone" type="string">
<column name="telephone" length="20" />
</property>
<property name="haspda" type="java.lang.Character">
<column name="haspda" length="1" />
</property>
<property name="deltag" type="java.lang.Character">
<column name="deltag" length="1" />
</property>
<property name="station" type="string">
<column name="station" length="40" />
</property>
<property name="standard" type="string">
<column name="standard" length="100" />
</property>
<set name="decidedzones" table="bc_decidedzone" inverse="true" lazy="true" fetch="select">
<key>
<column name="staff_id" length="32" />
</key>
<one-to-many class="Decidedzone" />
</set>
</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated 2017-8-15 16:30:28 by Hibernate Tools 4.0.0 -->
<hibernate-mapping>
<class name="com.hao.bos.entity.Subarea" table="bc_subarea">
<id name="id" type="string">
<column name="id" length="32" />
<generator class="assigned" />
</id>
<many-to-one name="decidedzone" class="Decidedzone" fetch="select">
<column name="decidedzone_id" length="32" />
</many-to-one>
<many-to-one name="region" class="Region" fetch="select">
<column name="region_id" length="32" />
</many-to-one>
<property name="addresskey" type="string">
<column name="addresskey" length="100" />
</property>
<property name="startnum" type="string">
<column name="startnum" length="30" />
</property>
<property name="endnum" type="string">
<column name="endnum" length="30" />
</property>
<property name="single" type="java.lang.Character">
<column name="single" length="1" />
</property>
<property name="position" type="string">
<column name="position" />
</property>
</class>
</hibernate-mapping>

时间: 2024-11-12 16:56:17

011 Hibernate反向工程构建实体和hbm文件 - bos的相关文章

MyEclipse Hibernate反向工程生成实体类

不废话,直接上步骤 step1.Window -> Open Perspective -> MyEclipse Database Explorer 到DB Broswer界面 step2.右键 -> New,新建一个数据库连接 step3.创建一个java项目 step4.给项目添加Hibernate Capabilities 项目 -> 右键 -> MyEclipse -> Add Hibernate Capabilities Add Hibernate Capabi

Hibernate tools 反向生成实体和hbm.xml文件

1 安装hibernate http://tools.jboss.org/downloads/overview.html 通过上面地址或者自己搜索hibernate tools官网找到update site 在eclipse 安装,安装中记住只选择hibernate tools部分即可 2 使用Hibernate tools 生成实体和hbm.xml文件 ① 创建 cfg.xml 右键工程 新建 接下来到对应页面,填写数据库信息生成文件 ② 配置console config ③ 创建reveng

自动生成hibernate的hbm文件

本文有待商榷 当我们在新增插件的时候发现会出现duplicate location,意思是所选的anchive所包含的zip路径已经复用,现象如下: 如上图所示黄色标记部分“Duplicate location”,这时,我们需要对先前添加的archive进行删除,过程如下: 1.进入window —— Preference ,选择Available Software Sites,弹出已经添加过的软件安装路径 2.选中已经添加过的路径,点击“Remove”,即可 是不是很神奇,这样,就不会出现无法

Hibernate反向工程使用心得

MyEclipse中的hibernate反向工程可以根据数据表自动为我们生成实体类,提高工作效率. 但是,hibernate中单向一对多,多对一,双向多对一关联底层的数据库结构是一样, 双向一对一,单向一对一关联的底层数据库也差不多. 所以在进行反向生成实体类时候需要在生成过程中进行一些设置来生成我们需要的关联关系. 首先必须在myeclipse中建立数据库连接和配置好hibernate环境, 详细可参考:http://blog.csdn.net/fycheung/article/details

Myeclipse6.0 的hibernate反向工程

Myeclipse6.0 的hibernate反向工程 第一步:建 DB Browser 方法一:Window -> Open Persipective -> MyEclipse Database Explorer 以后步骤同二 方法二: window / show view /other 选择如下图 最后,点击OK,在工作空间上将会出现一个DB Browser的配置页面,在配置页面空白处,右键,选择New按钮 在弹出的对话框当中配置数据库连接 点完成即可 点击 my_driver 可以new

自己手动安装hibernate tools for eclipse(Hibernate反向工程)

自己手动安装hibernate tools for eclipse(Hibernate反向工程) 用过myeclipse的人都知道,myeclipse有集成一个hibernate的可以根据数据库表自动生成mapping映射(xml 或annotation)以及java的pojo类的工具.其实hibernate官方网站就有提供一个这样的工具,当然,现在的 名字叫做jboss tools,而hibernate tools只是其中的一小部分. 对于像我这样的对myeclipse日渐臃肿而无法接受的人而

利用MyEclipse自动创建PO类、hbm文件(映射文件)、DAO

前提条件:表sjzdfl  表sjzdxx (使用数据库MySQL) 表sjzdfl (两个字段sjzdflId 和 sjzdflmc) 表sjzdfl 建表语句: [sql] view plaincopy DROP TABLE IF EXISTS `sjzdfl`; CREATE TABLE `sjzdfl` ( `sjzdflId` int(11) NOT NULL auto_increment, `sjzdflmc` varchar(255) default NULL, PRIMARY K

Hibernate3中重复引用hbm文件错误信息记录

Hibernate3中重复引用hbm文件错误信息记录. 2018 八月 12 11:17:09,778 ERROR - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginManager' defined in ServletContext resource [/WEB-INF/applicationCo

Hibernate反向工程生成DAO

通过Hibernate反向工程生成个DAO: package dao; import java.util.List; import org.hibernate.LockMode; import org.hibernate.Query; import org.hibernate.criterion.Example; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * A data access object (DAO) pr