Hibernate 三级关联笔记
Hibernate三级关联笔记
实体类关系如下:
→QingAoPlaceCdmaSector
QingAoCenterInfo→QingAoPlaceInfo→QingAoPlaceLteSector删除Center时要删除Center下所有的Place以及网元
→QingAoAp
实体类代码:
QingAoCenterInfo.java
packagecom.yuqiaotech.nttelcom.model;
importjava.util.Date;
importjava.util.List;
importjavax.persistence.CascadeType;
importjavax.persistence.Entity;
importjavax.persistence.FetchType;
importjavax.persistence.GeneratedValue;
importjavax.persistence.GenerationType;
importjavax.persistence.Id;
importjavax.persistence.JoinColumn;
importjavax.persistence.OneToMany;
importjavax.persistence.Table;
/**
*青奥重点场所信息表。
*
*/
@Entity(name="QING_AO_CENTER_INFO")
@Table(name="QING_AO_CENTER_INFO")
publicclassQingAoCenterInfo{
privateLongid;
privateStringcenterName;//重点场所名称
privateLongalarmNum;//告警数
privateStringnote;//备注
privateStringiconName;//图标名称
privateStringcityName;//所在城市
privateStringtype;//重点场所、活动保障
privateDatecreateTime;
privateList<QingAoPlaceInfo>qingAoPlaceInfo;//场所拥有的场馆
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
publicLonggetId(){
returnid;
}
publicvoidsetId(Longid){
this.id=id;
}
/**
*@searchItem
*displayType="text"
*
*重点场所名称
*@return
*/
publicStringgetCenterName(){
returncenterName;
}
publicvoidsetCenterName(StringcenterName){
this.centerName=centerName;
}
/**
*告警数
*@return
*/
publicLonggetAlarmNum(){
returnalarmNum;
}
publicvoidsetAlarmNum(LongalarmNum){
this.alarmNum=alarmNum;
}
/**
*备注
*@return
*/
publicStringgetNote(){
returnnote;
}
publicvoidsetNote(Stringnote){
this.note=note;
}
/**
*图标名称
*@return
*/
publicStringgetIconName(){
returniconName;
}
publicvoidsetIconName(StringiconName){
this.iconName=iconName;
}
publicStringgetCityName(){
returncityName;
}
publicvoidsetCityName(StringcityName){
this.cityName=cityName;
}
publicStringgetType(){
returntype;
}
publicvoidsetType(Stringtype){
this.type=type;
}
publicDategetCreateTime(){
returncreateTime;
}
publicvoidsetCreateTime(DatecreateTime){
this.createTime=createTime;
}
@OneToMany(mappedBy="qingAoCenterInfo",cascade=CascadeType.ALL)
publicList<QingAoPlaceInfo>getQingAoPlaceInfo(){
returnqingAoPlaceInfo;
}
publicvoidsetQingAoPlaceInfo(List<QingAoPlaceInfo>qingAoPlaceInfo){
this.qingAoPlaceInfo=qingAoPlaceInfo;
}
}
QingAoPlaceInfo.java
packagecom.yuqiaotech.nttelcom.model;
importjava.util.Date;
importjava.util.List;
importjavax.persistence.CascadeType;
importjavax.persistence.Entity;
importjavax.persistence.FetchType;
importjavax.persistence.GeneratedValue;
importjavax.persistence.GenerationType;
importjavax.persistence.Id;
importjavax.persistence.JoinColumn;
importjavax.persistence.ManyToOne;
importjavax.persistence.OneToMany;
importjavax.persistence.Table;
/**
*场馆信息。
*
*/
@Entity(name="QING_AO_PLACE_INFO")
@Table(name="QING_AO_PLACE_INFO")
publicclassQingAoPlaceInfo{
privateLongid;
privateQingAoCenterInfoqingAoCenterInfo;//重点场所id
privateStringplaceName;//场馆名称
privateStringnote;//备注
privateStringopenStat;//开通状态
privateLongdisplayOrder;
privateStringcityName;
privateDatecreateTime;
privateList<QingAoPlaceCdmaSector>qingAoPlaceCdmaSector;//拥有的cdma
privateList<QingAoPlaceLteSector>qingAoPlaceLteSector;//拥有的Lte
privateList<QingAoAp>qingAoAp;//拥有的Ap
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
publicLonggetId(){
returnid;
}
publicvoidsetId(Longid){
this.id=id;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="f_center_id")
publicQingAoCenterInfogetQingAoCenterInfo(){
returnqingAoCenterInfo;
}
publicvoidsetQingAoCenterInfo(QingAoCenterInfoqingAoCenterInfo){
this.qingAoCenterInfo=qingAoCenterInfo;
}
/**
*@searchItem
*displayType="text"
*场所名称
*@return
*/
publicStringgetPlaceName(){
returnplaceName;
}
publicvoidsetPlaceName(StringplaceName){
this.placeName=placeName;
}
publicStringgetNote(){
returnnote;
}
publicvoidsetNote(Stringnote){
this.note=note;
}
publicStringgetOpenStat(){
returnopenStat;
}
publicvoidsetOpenStat(StringopenStat){
this.openStat=openStat;
}
publicLonggetDisplayOrder(){
returndisplayOrder;
}
publicvoidsetDisplayOrder(LongdisplayOrder){
this.displayOrder=displayOrder;
}
publicStringgetCityName(){
returncityName;
}
publicvoidsetCityName(StringcityName){
this.cityName=cityName;
}
publicDategetCreateTime(){
returncreateTime;
}
publicvoidsetCreateTime(DatecreateTime){
this.createTime=createTime;
}
@OneToMany(mappedBy="qingAoPlaceInfo",cascade=CascadeType.ALL)
publicList<QingAoPlaceCdmaSector>getQingAoPlaceCdmaSector(){
returnqingAoPlaceCdmaSector;
}
publicvoidsetQingAoPlaceCdmaSector(
List<QingAoPlaceCdmaSector>qingAoPlaceCdmaSector){
this.qingAoPlaceCdmaSector=qingAoPlaceCdmaSector;
}
@OneToMany(mappedBy="qingAoPlaceInfo",cascade=CascadeType.ALL)
publicList<QingAoPlaceLteSector>getQingAoPlaceLteSector(){
returnqingAoPlaceLteSector;
}
publicvoidsetQingAoPlaceLteSector(
List<QingAoPlaceLteSector>qingAoPlaceLteSector){
this.qingAoPlaceLteSector=qingAoPlaceLteSector;
}
@OneToMany(mappedBy="qingAoPlaceInfo",cascade=CascadeType.ALL)
publicList<QingAoAp>getQingAoAp(){
returnqingAoAp;
}
publicvoidsetQingAoAp(List<QingAoAp>qingAoAp){
this.qingAoAp=qingAoAp;
}
}
QingAoPlaceCdmaSector.java
packagecom.yuqiaotech.nttelcom.model;
importjava.util.Date;
importjavax.persistence.CascadeType;
importjavax.persistence.Column;
importjavax.persistence.Entity;
importjavax.persistence.FetchType;
importjavax.persistence.GeneratedValue;
importjavax.persistence.GenerationType;
importjavax.persistence.Id;
importjavax.persistence.JoinColumn;
importjavax.persistence.ManyToOne;
importjavax.persistence.Table;
/**
*青奥场馆CDMA扇区信息
*
*@authorliuhao
*
*/
@Entity(name="QING_AO_PLACE_CDMA_SECTOR")
@Table(name="QING_AO_PLACE_CDMA_SECTOR")
publicclassQingAoPlaceCdmaSector{
privateLongid;
privateQingAoPlaceInfoqingAoPlaceInfo;//场馆id
privateLongsectorId;//扇区id
privateStringcityName;//地市
privateLongbsc;//bsc编号
privateLongbtsId;//基站编号
privateLongaccessSector;//扇区编号
privateStringsectorName;//扇区名称
privateStringsectorNameExcel;//扇区excel名称
privateStringopenStat;//开通状态
privateLongalarmNum;//告警数
privateDateupdateTime;//最后更新时间
privateLongpmAlarmNum;//性能告警数量
privateLongpositionLeft;
privateLongpositionTop;
privateLongdisplayOrder;
privateStringcellid;//1x小区号
privateStringcellidDo;//do小区号
privateDatecreateTime;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
publicLonggetId(){
returnid;
}
publicvoidsetId(Longid){
this.id=id;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="F_PLACE_ID")
publicQingAoPlaceInfogetQingAoPlaceInfo(){
returnqingAoPlaceInfo;
}
publicvoidsetQingAoPlaceInfo(QingAoPlaceInfoqingAoPlaceInfo){
this.qingAoPlaceInfo=qingAoPlaceInfo;
}
/**
*@searchItem
*displayType="text"
*@return
*/
publicLonggetSectorId(){
returnsectorId;
}
publicvoidsetSectorId(LongsectorId){
this.sectorId=sectorId;
}
publicStringgetCityName(){
returncityName;
}
publicvoidsetCityName(StringcityName){
this.cityName=cityName;
}
@Column(name="BSC")
publicLonggetBsc(){
returnbsc;
}
publicvoidsetBsc(Longbsc){
this.bsc=bsc;
}
@Column(name="BTS_ID")
publicLonggetBtsId(){
returnbtsId;
}
publicvoidsetBtsId(LongbtsId){
this.btsId=btsId;
}
@Column(name="ACCESS_SECTOR")
publicLonggetAccessSector(){
returnaccessSector;
}
publicvoidsetAccessSector(LongaccessSector){
this.accessSector=accessSector;
}
publicStringgetSectorName(){
returnsectorName;
}
publicvoidsetSectorName(StringsectorName){
this.sectorName=sectorName;
}
publicStringgetSectorNameExcel(){
returnsectorNameExcel;
}
publicvoidsetSectorNameExcel(StringsectorNameExcel){
this.sectorNameExcel=sectorNameExcel;
}
publicStringgetOpenStat(){
returnopenStat;
}
publicvoidsetOpenStat(StringopenStat){
this.openStat=openStat;
}
publicLonggetAlarmNum(){
returnalarmNum;
}
publicvoidsetAlarmNum(LongalarmNum){
this.alarmNum=alarmNum;
}
publicDategetUpdateTime(){
returnupdateTime;
}
publicvoidsetUpdateTime(DateupdateTime){
this.updateTime=updateTime;
}
publicLonggetPmAlarmNum(){
returnpmAlarmNum;
}
publicvoidsetPmAlarmNum(LongpmAlarmNum){
this.pmAlarmNum=pmAlarmNum;
}
publicLonggetPositionLeft(){
returnpositionLeft;
}
publicvoidsetPositionLeft(LongpositionLeft){
this.positionLeft=positionLeft;
}
publicLonggetPositionTop(){
returnpositionTop;
}
publicvoidsetPositionTop(LongpositionTop){
this.positionTop=positionTop;
}
publicLonggetDisplayOrder(){
returndisplayOrder;
}
publicvoidsetDisplayOrder(LongdisplayOrder){
this.displayOrder=displayOrder;
}
publicStringgetCellid(){
returncellid;
}
publicvoidsetCellid(Stringcellid){
this.cellid=cellid;
}
publicStringgetCellidDo(){
returncellidDo;
}
publicvoidsetCellidDo(StringcellidDo){
this.cellidDo=cellidDo;
}
publicDategetCreateTime(){
returncreateTime;
}
publicvoidsetCreateTime(DatecreateTime){
this.createTime=createTime;
}
}
QingAoPlaceLteSector.java
packagecom.yuqiaotech.nttelcom.model;
importjava.util.Date;
importjavax.persistence.CascadeType;
importjavax.persistence.Entity;
importjavax.persistence.FetchType;
importjavax.persistence.GeneratedValue;
importjavax.persistence.GenerationType;
importjavax.persistence.Id;
importjavax.persistence.JoinColumn;
importjavax.persistence.ManyToOne;
importjavax.persistence.Table;
/**
*青奥场馆Lte扇区信息。
*@authorjayce
*
*/
@Entity(name="QING_AO_PLACE_LTE_SECTOR")
@Table(name="QING_AO_PLACE_LTE_SECTOR")
publicclassQingAoPlaceLteSector{
privateLongid;
privateQingAoPlaceInfoqingAoPlaceInfo;//场馆具体place
privateLongsectorId;//扇区ID
privateStringcityName;//地市
privateLongsiteId;//基站编号
privateLongcellId;//小区标识
privateLonglocalCellId;//本地校区标识
privateStringsectorName;//扇区名称
privateStringsectorNameExcel;//扇区excel名称
privateStringopenStat;//开通状态
privateLongalarmNum;//告警数
privateDateupdateTime;//最后更新时间
privateLongpositionLeft;
privateLongpositionTop;
privateDatecreateTime;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
publicLonggetId(){
returnid;
}
publicvoidsetId(Longid){
this.id=id;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="f_place_id")
publicQingAoPlaceInfogetQingAoPlaceInfo(){
returnqingAoPlaceInfo;
}
publicvoidsetQingAoPlaceInfo(QingAoPlaceInfoqingAoPlaceInfo){
this.qingAoPlaceInfo=qingAoPlaceInfo;
}
/**
*@searchItem
*displayType="text"
*扇区ID
*@return
*/
publicLonggetSectorId(){
returnsectorId;
}
publicvoidsetSectorId(LongsectorId){
this.sectorId=sectorId;
}
/**
*@searchItem
*displayType="text"
*城市名称
*@return
*/
publicStringgetCityName(){
returncityName;
}
publicvoidsetCityName(StringcityName){
this.cityName=cityName;
}
/**
*@searchItem
*displayType="text"
*基站编号
*@return
*/
publicLonggetSiteId(){
returnsiteId;
}
publicvoidsetSiteId(LongsiteId){
this.siteId=siteId;
}
/**
*@searchItem
*displayType="text"
*校区编号
*@return
*/
publicLonggetCellId(){
returncellId;
}
publicvoidsetCellId(LongcellId){
this.cellId=cellId;
}
/**
*@searchItem
*displayType="text"
*本地小区编号
*@return
*/
publicLonggetLocalCellId(){
returnlocalCellId;
}
publicvoidsetLocalCellId(LonglocalCellId){
this.localCellId=localCellId;
}
/**
*@searchItem
*displayType="text"
*扇区名称
*@return
*/
publicStringgetSectorName(){
returnsectorName;
}
publicvoidsetSectorName(StringsectorName){
this.sectorName=sectorName;
}
/**
*@searchItem
*displayType="text"
*扇区excel名称
*@return
*/
publicStringgetSectorNameExcel(){
returnsectorNameExcel;
}
publicvoidsetSectorNameExcel(StringsectorNameExcel){
this.sectorNameExcel=sectorNameExcel;
}
publicStringgetOpenStat(){
returnopenStat;
}
publicvoidsetOpenStat(StringopenStat){
this.openStat=openStat;
}
publicLonggetAlarmNum(){
returnalarmNum;
}
publicvoidsetAlarmNum(LongalarmNum){
this.alarmNum=alarmNum;
}
/**
*@Editor
*type="date"
*@return
*/
publicDategetUpdateTime(){
returnupdateTime;
}
publicvoidsetUpdateTime(DateupdateTime){
this.updateTime=updateTime;
}
publicLonggetPositionLeft(){
returnpositionLeft;
}
publicvoidsetPositionLeft(LongpositionLeft){
this.positionLeft=positionLeft;
}
publicLonggetPositionTop(){
returnpositionTop;
}
publicvoidsetPositionTop(LongpositionTop){
this.positionTop=positionTop;
}
publicDategetCreateTime(){
returncreateTime;
}
publicvoidsetCreateTime(DatecreateTime){
this.createTime=createTime;
}
}
QingAoAp.java
packagecom.yuqiaotech.nttelcom.model;
importjava.util.Date;
importjavax.persistence.Entity;
importjavax.persistence.FetchType;
importjavax.persistence.GeneratedValue;
importjavax.persistence.GenerationType;
importjavax.persistence.Id;
importjavax.persistence.JoinColumn;
importjavax.persistence.ManyToOne;
importjavax.persistence.Table;
/**
*城市热点WiFi
*@authorliuhao
*
*/
@Entity(name="QING_AO_AP")
@Table(name="QING_AO_AP")
publicclassQingAoAp{
privateLongid;
privateStringapName;
privateStringposition;
privateStringip;
privateLongdeviceId;
privateStringapNameExcel;
privateQingAoPlaceInfoqingAoPlaceInfo;
privateStringcityName;
privateDatecreateTime;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
publicLonggetId(){
returnid;
}
publicvoidsetId(Longid){
this.id=id;
}
/**
*@searchItem
*displayType="text"
*@return
*/
publicStringgetApName(){
returnapName;
}
publicvoidsetApName(StringapName){
this.apName=apName;
}
/**
*@searchItem
*displayType="text"
*@return
*/
publicStringgetPosition(){
returnposition;
}
publicvoidsetPosition(Stringposition){
this.position=position;
}
publicStringgetIp(){
returnip;
}
publicvoidsetIp(Stringip){
this.ip=ip;
}
publicLonggetDeviceId(){
returndeviceId;
}
publicvoidsetDeviceId(LongdeviceId){
this.deviceId=deviceId;
}
publicStringgetApNameExcel(){
returnapNameExcel;
}
publicvoidsetApNameExcel(StringapNameExcel){
this.apNameExcel=apNameExcel;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="F_PLACE_ID")
publicQingAoPlaceInfogetQingAoPlaceInfo(){
returnqingAoPlaceInfo;
}
publicvoidsetQingAoPlaceInfo(QingAoPlaceInfoqingAoPlaceInfo){
this.qingAoPlaceInfo=qingAoPlaceInfo;
}
publicStringgetCityName(){
returncityName;
}
publicvoidsetCityName(StringcityName){
this.cityName=cityName;
}
publicDategetCreateTime(){
returncreateTime;
}
publicvoidsetCreateTime(DatecreateTime){
this.createTime=createTime;
}
}