版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
JavaHibernateOne-to-Many关联映Many-to-One关联映基于Account实现joinfetch查基于Account实现级联添加和删新建项目
图- CREATETABLE NUMBER(9)CONSTRAINTACCOUNT_ID_PKPRIMARY NUMBER(9) REFERENCES NOTCONSTRAINTACCOUNT_LOGIN_NAME_UK VARCHAR2(30)NOT CONSTRAINTCHECK(STATUSIN(0,1,2)), DEFAULT NOT NOTCONSTRAINTACCOUNT_INCARD_NO CHAR(1)CONSTRAINTCHECK(GENDERIN(0,1)), VARCHAR2(15)NOT ALTERSESSIONSETNLS_DATE_FORMAT='yyyymmddINSERTINTO VALUES(1005,NULL,'taiji001','256528',1,'200803INSERTINTO VALUES(1010,NULL,'xl18z60','190613',1,'200901 INSERTINTO VALUES(1011,1010,'dgbf70','270429',1,'200903 INSERTINTO VALUES(1015,1005,'mjjzh64','041115',1,'201003 INSERTINTO VALUES(1018,1011,'jmdxj00','010322',1,'201101.INSERTINTO VALUES(1019,1011,'ljxj90','310346',1,'201202 INSERTINTO VALUES(1020,NULL,'kxhxd20','012115',1,'201202CREATETABLENUMBER(10)CONSTRAINTSERVICE_ID_PKPRIMARYNUMBER(9)CONSTRAINTREFERENCESACCOUNT(ID)NOTVARCHAR2(15)CONSTRAINTREFERENCESHOST(ID)NOTNULLNOTCONSTRAINTVARCHAR2(8)NOTCONSTRAINTCHECESTAFL(T packageimportimportjava.util.HashSet;importjava.util.Set;NUMBER(4)CONSTRAINTREFERENCESCOST(ID)NOTcreatesequencecreatesequence新建*Accountentity.@authorMyEclipsePersistence publicclassAccountimplementsjava.io.Serializable{//privateIntegerprivate privateStringprivateStringprivateStringprivateDateprivateDateprivateDateprivateStringprivateStringprivateDateprivateStringprivateStringprivate private privateStringprivateStringprivateStringprivateDateprivateStringlastLoginIp;//Propertypublic menderId()return public menderId)menderId publicIntegergetId()return}publicvoidsetId(Integerid)this.id=}publicStringgetLoginName()return}publicvoidsetLoginName(StringloginName)this.loginName=}publicStringgetLoginPasswd()return}publicvoidsetLoginPasswd(String{this.loginPasswd=}publicStringgetStatus()return}publicvoidsetStatus(Stringstatus)this.status=}publicDategetCreateDate()return}publicvoidsetCreateDate(DatecreateDate)this.createDate=}publicDategetPauseDate()return publicvoidsetPauseDate(Date{this.pauseDate=}publicDategetCloseDate()return}publicvoidsetCloseDate(Date{this.closeDate=}publicStringgetRealName()return}publicvoidsetRealName(String{this.realName=}publicStringgetIdcardNo()return}publicvoidsetIdcardNo(String{this.idcardNo=}publicDategetBirthdate()return}publicvoidsetBirthdate(Date{this.birthdate=}publicStringgetGender()return publicvoidsetGender(Stringgender)this.gender= publicStringgetOccupation()return publicvoidsetOccupation(Stringoccupation)this.occupation= publicString ephone()return publicvoid ephone) ephone publicString ()return publicvoid ) publicStringgetMailaddress()return publicvoidsetMailaddress(Stringmailaddress)this.mailaddress= publicStringgetZipcode()return publicvoidsetZipcode(Stringzipcode)this.zipcode= publicStringgetQq()return publicvoidsetQq(Stringqq)this.qq= publicDategetLastLoginTime()return publicvoidsetLastLoginTime(DatelastLoginTime)this.lastLoginTime= publicStringgetLastLoginIp()return publicvoidsetLastLoginIp(StringlastLoginIp)this.lastLoginIp= 新建package import*Serviceentity.@authorMyEclipsePersistencepublicclassServiceimplements{//privateIntegerprivateStringprivateIntegerprivateIntegerprivateStringprivateStringprivateStringprivateDateprivateDateprivateDatecloseDate;publicIntegergetId()return}publicvoidsetId(Integer{this.id=}publicIntegergetCostId()return}publicvoidcostId)this.costId=}publicStringgetUnixHost()return}publicvoidsetUnixHost(StringunixHost)this.unixHost= publicIntegergetAccountId()return publicvoidsetAccountId(IntegeraccountId)this.accountId= publicStringgetOsUsername()return publicvoidsetOsUsername(StringosUsername)this.osUsername= publicStringgetLoginPasswd()return publicvoidsetLoginPasswd(StringloginPasswd)this.loginPasswd= publicStringgetStatus()return publicvoidsetStatus(Stringstatus)this.status= publicDategetCreateDate()return publicvoidsetCreateDate(DatecreateDate)this.createDate= publicDategetPauseDate()return publicvoidsetPauseDate(DatepauseDate)this.pauseDate= publicDategetCloseDate()return}publicvoidsetCloseDate(DatecloseDate){this.closeDate=closeDate;}}新建<?xmlversion="1.0"encoding="utf-<!DOCTYPEhibernate- PUBLIC"-//Hibernate/Hibernate DTD <!- fileautogeneratedbyMyEclipsePersistence--<hibernate- <classname="ctoss.pojo.Account"table="ACCOUNT"<idname="id"<columnname="ID"precision="9"scale="0"<generator<param<property menderId"<column <propertyname="loginName"<columnname="LOGIN_NAME"length="30"not-null="true"<propertyname="loginPasswd"<columnname="LOGIN_PASSWD"length="30"not-null="true"<propertyname="status"<columnname="STATUS"length="1"<propertyname="createDate"<columnname="CREATE_DATE"length="7"<propertyname="pauseDate"<columnname="PAUSE_DATE"length="7"<propertyname="closeDate"<columnname="CLOSE_DATE"length="7"<propertyname="realName"<columnname="REAL_NAME"length="20"not-null="true"<propertyname="idcardNo"<columnname="IDCARD_NO"length="18"not-null="true"<propertyname="birthdate"<columnname="BIRTHDATE"length="7"<propertyname="gender"<columnname="GENDER"length="1"<propertyname="occupation"<columnname="OCCUPATION"length="50"<property ephone"<column EPHONE"length="15"not-null="true"<property "<column "length="50"<propertyname="mailaddress"<columnname="MAILADDRESS"length="50"<propertyname="zipcode"<columnname="ZIPCODE"length="6"<propertyname="qq"<columnname="QQ"length="15"<propertyname="lastLoginTime"<columnname="LAST_LOGIN_TIME"length="7"<propertyname="lastLoginIp"<columnname="LAST_LOGIN_IP"length="15">新建<?xmlversion="1.0"encoding="utf-<!DOCTYPEhibernate- PUBLIC"-//Hibernate/Hibernate DTD <!- fileautogeneratedbyMyEclipsePersistence--<hibernate- <classname="ctoss.pojo.Service"table="SERVICE"<idname="id"<columnname="ID"precision="10"scale="0"<generator<param<propertyname="unixHost"<columnname="UNIX_HOST"<propertyname="costId"<columnname="COST_ID"<propertyname="osUsername"<columnname="OS_USERNAME"length="8"not-null="true"<propertyname="loginPasswd"<columnname="LOGIN_PASSWD"length="8"not-null="true"<propertyname="status"<columnname="STATUS"length="1"<propertyname="createDate"<columnname="CREATE_DATE"length="7"<propertyname="pauseDate"<columnname="PAUSE_DATE"length="7"<propertyname="closeDate"<columnname="CLOSE_DATE"length="7"><?xmlversion='1.0'encoding='UTF-hibernate-configuration"-//Hibernate/HibernateConfigurationDTD3.0//EN"<!--GeneratedbyMyEclipseHibernate<hibernate---<session-<property<propertyname="connection.url"><property<property<!--将hibernate底层执行的sql<property<propertyresource="com/tarena/netctoss/pojo/Service.hbm.xml"resource="com/tarena/netctoss/pojo/Account.hbm.xml"</session-AccountaccAccount)session.get(Account.class,1);Queryquery=session.createQuery("fromServiceswheres.accountId=1");List<Item>list=query.list();提供的修改我们期望:当执行(Account)session.get(Account.class1);语句,取出Account后,在属性packageimportimportjava.util.HashSet;importjava.util.Set;*Accountentity.@authorMyEclipsePersistencepublicclassAccountimplementsjava.io.Serializable//privateIntegerprivate privateStringprivateStringprivateStringprivateDateprivateDateprivateDateprivateStringprivateStringprivateDateprivateStringprivateStringprivate private privateStringprivateStringprivateStringprivateDateprivateStringprivateSet<Service>services=newHashSet<Service>();//Propertypublic menderId()return }public menderId)menderId }publicSet<Service>getServices()return}publicvoidsetServices(Set<Service>services)this.services=}publicIntegergetId()return}publicvoidsetId(Integerid)this.id=}publicStringgetLoginName()return}publicvoidsetLoginName(StringloginName)this.loginName=}publicStringgetLoginPasswd()return}publicvoidsetLoginPasswd(String{this.loginPasswd=}publicStringgetStatus()return}publicvoidsetStatus(Stringstatus)this.status=}publicDategetCreateDate()return}publicvoidsetCreateDate(DatecreateDate)this.createDate= publicDategetPauseDate()return}publicvoidsetPauseDate(Date{this.pauseDate=}publicDategetCloseDate()return}publicvoidsetCloseDate(Date{this.closeDate=}publicStringgetRealName()return}publicvoidsetRealName(String{this.realName=}publicStringgetIdcardNo()return}publicvoidsetIdcardNo(String{this.idcardNo=}publicDategetBirthdate()return publicvoidsetBirthdate(Datebirthdate)this.birthdate= publicStringgetGender()return publicvoidsetGender(Stringgender)this.gender= publicStringgetOccupation()return publicvoidsetOccupation(Stringoccupation)this.occupation= publicString ephone()return publicvoid ephone) ephone publicString ()return publicvoid ) publicStringgetMailaddress()return publicvoidsetMailaddress(Stringmailaddress)this.mailaddress=}publicStringgetZipcode()return}publicvoidsetZipcode(String{this.zipcode=}publicStringgetQq()return}publicvoidsetQq(Stringqq)this.qq=}publicDategetLastLoginTime()return publicvoidsetLastLoginTime(DatelastLoginTime)this.lastLoginTime= publicStringgetLastLoginIp()return publicvoidsetLastLoginIp(StringlastLoginIp)this.lastLoginIp= <set<columnname="ACCOUNT_ID"<one-to-manyclass="ctoss.pojo.Service"/><?xmlversion="1.0"encoding="utf-<!DOCTYPEhibernate- PUBLIC"-//Hibernate/Hibernate DTD <!- fileautogeneratedbyMyEclipsePersistence--<hibernate- <classname="ctoss.pojo.Account"table="ACCOUNT"<idname="id"<columnname="ID"precision="9"scale="0"<generator<param<property menderId"<column <propertyname="loginName"<columnname="LOGIN_NAME"length="30"not-null="true"<propertyname="loginPasswd"<columnname="LOGIN_PASSWD"length="30"not-null="true"<propertyname="status"<columnname="STATUS"length="1"<propertyname="createDate"<columnname="CREATE_DATE"length="7"<propertyname="pauseDate"<columnname="PAUSE_DATE"length="7"<propertyname="closeDate"<columnname="CLOSE_DATE"length="7"<propertyname="realName"<columnname="REAL_NAME"length="20"not-null="true"<propertyname="idcardNo"<columnname="IDCARD_NO"length="18"not-null="true"<propertyname="birthdate"<columnname="BIRTHDATE"length="7"<propertyname="gender"<columnname="GENDER"length="1"<propertyname="occupation"<columnname="OCCUPATION"length="50"<property ephone"<column EPHONE"length="15"not-null="true"<property "<column "length="50"<propertyname="mailaddress"<columnname="MAILADDRESS"length="50"<propertyname="zipcode"<columnname="ZIPCODE"length="6"<propertyname="qq"<columnname="QQ"length="15"<propertyname="lastLoginTime"<columnname="LAST_LOGIN_TIME"length="7"<propertyname="lastLoginIp"<columnname="LAST_LOGIN_IP"length="15"<set<columnname="ACCOUNT_ID"<one-to-manyclass="ctoss.pojo.Service">新建packageimportimportorg.hibernate.SessionFactory;importorg.hibernate.cfg.Configuration;publicclassHibernateUtilprivatestaticSessionFactoryprivatestaticThreadLocal<Session>sessionLocal=newThreadLocal<Session>();Configurationconf=new//获取sf=}publicstaticvoidSessionsession=if(session!=null){}}}}publicstaticSessionSessionsession=sessionLocal.get();if(session==null){//新建一个session=sf.openSession();}ctoss.pojo.Service;ctoss.util.HibernateUtil;publicclassTestOneToMany*@parampublicstaticvoidmain(String[]{Sessionsession=Accountaccount=(Account)session.get(Account.class,System.out.println(account.getRealName()+"for(Services:}}account0_.IDasMENDER_IDaccount0_.LOGIN_NAMEasaccount0_.LOGIN_PASSWDasLOGIN4_1_0_,account0_.STATUSasSTATUS1_0_,account0_.CREATE_DATEasCREATE6_1_0_,account0_.PAUSE_DATEasPAUSE7_1_0_,account0_.CLOSE_DATEasaccount0_.REAL_NAMEasaccount0_.IDCARD_NOasIDCARD10_1_0_,account0_.BIRTHDATEasBIRTHDATE1_0_,account0_.GENDERasGENDER1_0_,account0_.OCCUPATIONasEPHONE account0_.MAILADDRESSasaccount0_.ZIPCODEasZIPCODE1_0_,account0_.QQasQQ1_0_,account0_.LAST_LOGIN_TIMEasaccount0_.LAST_LOGIN_IPasTASK.ACCOUNTservices0_.ACCOUNT_IDasservices0_.IDasservices0_.IDasservices0_.UNIX_HOSTasservices0_.COST_IDasservices0_.ACCOUNT_IDasservices0_.OS_USERNAMEasservices0_.LOGIN_PASSWDasservices0_.STATUSasservices0_.CREATE_DATEasservices0_.PAUSE_DATEasservices0_.CLOSE_DATEasTASK.SERVICEeCREATETABLENUMBER(9)CONSTRAINTACCOUNT_ID_PKPRIMARYNUMBER(9)REFERENCESNOTCONSTRAINTACCOUNT_LOGIN_NAME_UKVARCHAR2(30)NOT CONSTRAINTCHECK(STATUSIN(0,1,2)), DEFAULT NOT NOTCONSTRAINTACCOUNT_INCARD_NO CHAR(1)CONSTRAINTCHECK(GENDERIN(0,1)), VARCHAR2(15)NOT ALTERSESSIONSETNLS_DATE_FORMAT='yyyymmddINSERTINTO VALUES(1005,NULL,'taiji001','256528',1,'200803INSERTINTO VALUES(1010,NULL,'xl18z60','190613',1,'200901 INSERTINTO VALUES(1011,1010,'dgbf70','270429',1,'200903 INSERTINTO VALUES(1015,1005,'mjjzh64','041115',1,'201003 INSERTINTO 01INSERTINTOVALUES(1019,1011,'ljxj90','310346',1,'201202'INSERTINTOVALUES(1020,NULL,'kxhxd20','012115',1,'201202CREATETABLENUMBER(10)CONSTRAINTSERVICE_ID_PKPRIMARYNUMBER(9)CONSTRAINTREFERENCESACCOUNT(ID)NOTVARCHAR2(15)CONSTRAINTREFERENCESHOST(ID)NOTNULLNOTCONSTRAINTVARCHAR2(8)NOTCONSTRAINTCHECESTAFL(TNUMBER(4)CONSTRAINTREFERENCESCOST(ID)NOTINSERTINTOSERVICEVALUESINSERTINTOSERVICEVALUESpackageimportimportjava.util.HashSet;importjava.util.Set;publicclassAccountimplementsjava.io.Serializable//privateIntegerprivatecreatesequencecreatesequence*Accountentity.@authorPersistenceprivateStringprivateStringprivateStringprivateDateprivateDateprivateDateprivateStringprivateStringprivateDateprivateStringprivateStringprivate private privateStringprivateStringprivateStringprivateDateprivateStringprivateSet<Service>services=newHashSet<Service>();//Propertypublic menderId()return public menderId)menderId publicSet<Service>getServices()return publicvoidsetServices(Set<Service>services)this.services= publicIntegergetId()return publicvoidsetId(Integerid)this.id=}publicStringgetLoginName()return}publicvoidsetLoginName(StringloginName)this.loginName=}publicStringgetLoginPasswd()return}publicvoidsetLoginPasswd(String{this.loginPasswd=}publicStringgetStatus()return}publicvoidsetStatus(Stringstatus)this.status=}publicDategetCreateDate()return}publicvoidsetCreateDate(DatecreateDate)this.createDate=}publicDategetPauseDate()return}publicvoidsetPauseDate(Date{this.pauseDate=}publicDategetCloseDate()return}publicvoidsetCloseDate(Date{this.closeDate=}publicStringgetRealName()return}publicvoidsetRealName(String{this.realName=}publicStringgetIdcardNo()return}publicvoidsetIdcardNo(String{this.idcardNo=}publicDategetBirthdate()return}publicvoidsetBirthdate(Datebirthdate)this.birthdate= publicStringgetGender()return publicvoidsetGender(Stringgender)this.gender= publicStringgetOccupation()return publicvoidsetOccupation(Stringoccupation)this.occupation= publicString ephone()return publicvoid ephone) ephone publicString ()return publicvoid ) publicStringgetMailaddress()return}publicvoidsetMailaddress(Stringmailaddress)this.mailaddress= publicStringgetZipcode()return publicvoidsetZipcode(Stringzipcode)this.zipcode= publicStringgetQq()return publicvoidsetQq(Stringqq)this.qq= publicDategetLastLoginTime()return publicvoidsetLastLoginTime(DatelastLoginTime)this.lastLoginTime= publicStringgetLastLoginIp()return publicvoidsetLastLoginIp(StringlastLoginIp)this.lastLoginIp= package import*Serviceentity.@authorMyEclipsePersistencepublicclassServiceimplementsjava.io.Serializable{//privateIntegerprivateStringprivateIntegerprivateIntegerprivateStringprivateStringprivateStringprivateDateprivateDateprivateDatecloseDate;publicIntegergetId()return publicvoidsetId(Integerid)this.id= publicIntegergetCostId()return publicvoidsetCostId(IntegercostId)this.costId= publicStringgetUnixHost()return}publicvoidsetUnixHost(StringunixHost)this.unixHost=}publicIntegergetAccountId()return}publicvoidsetAccountId(IntegeraccountId)this.accountId=}publicStringgetOsUsername()return}publicvoidsetOsUsername(StringosUsername)this.osUsername=}publicStringgetLoginPasswd()return}publicvoidsetLoginPasswd(String{this.loginPasswd=}publicStringgetStatus()return}publicvoidsetStatus(Stringstatus)this.status=}publicDategetCreateDate()return}publicvoidsetCreateDate(DatecreateDate)this.createDate=}publicDategetPauseDate() return publicvoidsetPauseDate(DatepauseDate)this.pauseDate=}publicDategetCloseDate(){returncloseDate;}publicvoidsetCloseDate(DatecloseDate){this.closeDate=closeDate;}}<?xmlversion="1.0"encoding="utf-<!DOCTYPEhibernate- PUBLIC"-//Hibernate/Hibernate DTD <!- fileautogeneratedbyMyEclipsePersistence--<hibernate- <classname="ctoss.pojo.Account"table="ACCOUNT"<idname="id"<columnname="ID"precision="9"scale="0"<generator<param<property menderId"<column <propertyname="loginName"<columnname="LOGIN_NAME"length="30"not-null="true"<propertyname="loginPasswd"<columnname="LOGIN_PASSWD"length="30"not-null="true"<propertyname="status"<columnname="STATUS"length="1"<propertyname="createDate"<columnname="CREATE_DATE"length="7"<propertyname="pauseDate"<columnname="PAUSE_DATE"length="7"<propertyname="closeDate"<columnname="CLOSE_DATE"length="7"<propertyname="realName"<columnname="REAL_NAME"length="20"not-null="true"<propertyname="idcardNo"<columnname="IDCARD_NO"length="18"not-null="true"<propertyname="birthdate"<columnname="BIRTHDATE"length="7"<propertyname="gender"<columnname="GENDER"length="1"<propertyname="occupation"<columnname="OCCUPATION"length="50"<property ephone"<column EPHONE"length="15"not-null="true"<property "<column "length="50"<propertyname="mailaddress"<columnname="MAILADDRESS"length="50"<propertyname="zipcode"<columnname="ZIPCODE"length="6"<propertyname="qq"<columnname="QQ"length="15"<propertyname="lastLoginTime"<columnname="LAST_LOGIN_TIME"length="7"<propertyname="lastLoginIp"<columnname="LAST_LOGIN_IP"length="15"<set<columnname="ACCOUNT_ID"<one-to-manyclass="ctoss.pojo.Service"><?xmlversion="1.0"encoding="utf-<!DOCTYPEhibernate-"<!-PUBLIC"-//Hibernate/HibernateDTDfileautogeneratedbyMyEclipsePersistence--<hibernate-><classname="ctoss.pojo.Service"table="SERVICE"<idname="id"<columnname="ID"precision="10"scale="0"<generator<param<propertyname="unixHost"<column<propertyname="costId"<columnname="COST_ID"<propertyname="osUsername"<columnname="OS_USERNAME"length="8"not-null="true"<propertyname="loginPasswd"<columnname="LOGIN_PASSWD"length="8"not-<propertyname="status"<columnname="STATUS"length="1"<propertyname="createDate"<columnname="CREATE_DATE"length="7"<propertyname="pauseDate"<columnname="PAUSE_DATE"length="7"<propertyname="closeDate"<columnname="CLOSE_DATE"length="7"><?xmlversion='1.0'encoding='UTF-<!DOCTYPEhibernate-configuration"-//Hibernate/HibernateConfigurationDTD3.0//EN"<!--GeneratedbyMyEclipseHibernate<hibernate---<session-<propertyname="dialect"><property<property<property<property<!--将hibernate底层执行的sql<property<property resource="com/tarena/netctoss/pojo/Service.hbm.xml" resource="com/tarena/netctoss/pojo/Account.hbm.xml"</session-packageimportimportorg.hibernate.SessionFactory;importorg.hibernate.cfg.Configuration;publicclassHibernateUtilprivatestaticSessionFactoryprivatestaticThreadLocal<Session>sessionLocal=newThreadLocal<Session>();Configurationconf=new//获取sf=}}publicstaticvoidSessionsession=if(session!=null){}}}publicstaticSessionSessionsession=sessionLocal.get();if(session==null){//新建一个session=sf.openSession();}ctoss.pojo.Service;ctoss.util.HibernateUtil;publicclassTestOneToMany*@parampublicstaticvoidmain(String[]args)Sessionsession=Accountaccount=(Account)session.get(Account.class,System.out.println(account.getRealName()+""+account.getIdcardNo()for(Services:account.getServices()){System.out.println(s.getId()+"}}}packageimport*Serviceentity.@authorMyEclipsePersistencepublicclassServiceimplementsjava.io.Serializable//privateprivateprivateIntegerStringunixHost;IntegercostId; privateIntegerprivateAccountprivateStringprivateStringprivateStringprivateDateprivateDateprivateDatecloseDate;publicIntegergetId()return publicvoidsetId(Integerid)this.id= publicIntegergetCostId()return publicvoidsetCostId(IntegercostId)this.costId= publicStringgetUnixHost()return publicvoidsetUnixHost(StringunixHost)this.unixHost= publicAccountgetAccount()return publicvoidsetAccount(Accountaccount)this.account= publicIntegergetAccountId() return publicvoidsetAccountId(IntegeraccountId)this.accountId= publicStringgetOsUsername()return publicvoidsetOsUsername(StringosUsername)this.osUsername= publicStringgetLoginPasswd()return publicvoidsetLoginPasswd(StringloginPasswd)this.loginPasswd= publicStringgetStatus()return publicvoidsetStatus(Stringstatus)this.status= publicDategetCreateDate()return publicvoidsetCreateDate(DatecreateDate)this.createDate= publicDategetPauseDate()return publicvoidsetPauseDate(DatepauseDate)this.pauseDate= publicDategetCloseDate()return publicvoidsetCloseDate(DatecloseDate)this.closeDate= <many-to-onename="account"</many-to-<?xmlversion="1.0"encoding="utf-<!DOCTYPEhibernate- PUBLIC"-//Hibernate/Hibernate DTD <!- fileautogeneratedbyMyEclipsePersistence--<hibernate- <classname="ctoss.pojo.Service"table="SERVICE"<idname="id"<columnname="ID"precision="10"scale="0"<generator<param<propertyname="unixHost"<columnname="UNIX_HOST"<propertyname="costId"<columnname="COST_ID"<many-to-onename="account"</many-to-<propertyname="osUsername"<columnname="OS_USERNAME"length="8"not-null="true"<propertyname="loginPasswd"<columnname="LOGIN_PASSWD"length="8"not-null="true"<propertyname="status"<columnname="STATUS"length="1"<propertyname="createDate"<columnname="CREATE_DATE"length="7"<propertyname="pauseDate"<columnname="PAUSE_DATE"length="7"<propertyname="closeDate"<columnname="CLOSE_DATE"length="7">ctoss.pojo.Service;ctoss.util.HibernateUtil;publicclassTestManyToOne*@parampublicstaticvoidmain(String[]{Sessionsession=Serviceservice=(Service)session.get(Service.class,2002);System.out.println(service.getId()+"System.out.println(service.getAccount().getId()+"}}service0_.IDasservice0_.UNIX_HOSTasservice0_.COST_IDasservice0_.ACCOUNT_IDasservice0_.OS_USERNAMEasservice0_.LOGIN_PASSWDasservice0_.STATUSasservice0_.CREATE_DATEasservice0_.PAUSE_DATEasservice0_.CLOSE_DATEasTASK.SERVICE2002account0_.IDasMENDER_ID account0_.LOGIN_NAMEasaccount0_.LOGIN_PASSWDasaccount0_.STATUSasaccount0_.CREATE_DATEasaccount0_.PAUSE_DATEasaccount0_.CLOSE_DATEasaccount0_.REAL_NAMEasaccount0_.IDCARD_NOasaccount0_.BIRTHDATEasaccount0_.GENDERasaccount0_.OCCUPATIONas EPHONE account0_.MAILADDRESSasaccount0_.ZIPCODEasZIPCODE1_0_,account0_.QQasQQ1_0_,account0_.LAST_LOGIN_TIMEasLAST19_1_0_,account0_.LAST_LOGIN_IPasLAST20_1_0_TASK.ACCOUNTaccount0_1011packageimport*Serviceentity.@authorMyEclipsePersistencepublicclassServiceimplementsjava.io.SerializableprivateDateprivateDatepauseDate;privateDate//privateIntegerprivateStringprvtIeectd;privateAccountprivateStringprivateStringprivateStringpublicIntegergetId()return publicvoidsetId(Integerid)this.id= publicIntegergetCostId()return publicvoidsetCostId(IntegercostId)this.costId= publicStringgetUnixHost()return}publicvoidsetUnixHost(String{this.unixHost=}publicAccountgetAccount()return}publicvoidsetAccount(Accountaccount)this.account=}publicIntegergetAccountId()return}publicvoidsetAccountId(Integer{this.accountId=}publicStringgetOsUsername()return publicvoidsetOsUsername(StringosUsername)this.osUsername= publicStringgetLoginPasswd()return publicvoidsetLoginPasswd(StringloginPasswd)this.loginPasswd= publicStringgetStatus()return publicvoidsetStatus(Stringstatus)this.status= publicDategetCreateDate()return publicvoidsetCreateDate(DatecreateDate)this.createDate=}publicDategetPauseDate()return}publicvoidsetPauseDate(Date{this.pauseDate=}publicDategetCloseDate()return}publicvoidsetCloseDate(Date{this.closeDate=}}<?xmlversion="1.0"encoding="utf-<!DOCTYPEhibernate-PUBLIC"-//Hibernate/HibernateDTD"<!-MapfileautogeneratedbyMyEclipsePersistence--<classname="ctoss.pojo.Service"<idname="id"<columnname="ID"precision="10"scale="0"<generator<param<propertyname="unixHost"<columnname="UNIX_HOST"<propertyname="costId"<columnname="COST_ID"<many-to-onename="account"</many-to-<propertyname="osUsername"<columnname="OS_USERNAME"length="8"not-<propertyname="loginPasswd"<columnname="LOGIN_PASSWD"length="8"not-<propertyname="status"<columnname="STATUS"length="1"<propertyname="createDate"<columnname="CREATE_DATE"length="7"<propertyname="pauseDate"<columnname="PAUSE_DATE"length="7"<propertyname="closeDate"<columnname="CLOSE_DATE"length="7">packageimportimportimportpublicclassTestManyToOne*@parampublicstaticvoidmain(String[]{Sessionsession=Serviceservice=(Service)session.get(Service.class,2002);System.out.println(service.getId()+""+service.getOsUsername());System.out.println(service.getAccount().getId()+"}基于Account实现joinfetch在“Many-to-One关联映射”案例的基础上,完成当前案例。当前案例测试joinfetch查询在//Stringhql="fromServicesjoinfetchs.accountwhereStringhql="fromServiceswhe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 事业单位员工合同协议书
- 企业资产购置合同模板
- 机构用工合同协议书
- 实验室合作协议范本
- 工业厂房租赁合同标准文本
- 期货交易数据服务协议
- 广东省室内装潢设计工程施工合同示例
- 保安服务合同协议书范本
- 房屋翻新合同的范本
- 广东省批发花卉选购合同
- OSA患者围术期管理的专家共识
- 陕西省西安市碑林区2023-2024学年三年级上学期期中数学试卷
- 河北省沧衡八校联盟2023-2024学年高二上学期11月期中数学试题
- 我的家乡湖北咸宁介绍
- 幼教培训课件:《幼儿园班级区域创设》
- 行政办公室行政办公管理检查开展情况汇报
- 大课间跑操评分表
- 老旧小区改造室外给排水工程施工方案和技术措施
- 食品的感官检验-感官检验的常用方法(食品检测技术课件)
- 传染病护理学高职PPT完整全套教学课件
- 智慧校园创建工作课件
评论
0/150
提交评论