|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
java也能做一些底层语言开发做的事情(难度很高,不是java顶尖高手是做不来的),一对一干系的保护有两种,分为主键联系关系和独一外键联系关系一对一干系的保护有两种,分为主键联系关系和独一外键联系关系主键联系关系:(双向)(主控方)Person.javaPerson{privateStringusername;//对被控方的援用privateAddressaddress;publicStringgetUsername(){returnusername;}publicvoidsetUsername(Stringusername){this.username=username;}publicAddressgetAddress(){returnaddress;}publicvoidsetAddress(Addressaddress){this.address=address;}}(主动方)Address.javaAddress{privateStringaddressName;//对主控方的援用privatePersonperson;publicStringgetAddressName(){returnaddressName;}publicvoidsetAddressName(StringaddressName){this.addressName=addressName;}publicPersongetPerson(){returnperson;}publicvoidsetPerson(Personperson){this.person=person;}publicStringtoString(){returnnewToStringBuilder(this).append("addressName",addressName).toString();}publicbooleanequals(Objecto){if(!(oinstanceofAddress){returnfalse;}Addressrhs=(Address)o;returnnewEqualsBuilder().appendSuper(super.equals(o)).append(this.addressName,rhs.getAddressName()).isEquals();}publicinthashCode(){returnnewHashCodeBuilder(17,37).append(addressName).toHashCode();}}mapping文件<classname="Person"table="person"><idname="id"type="long"column="id"><generatorclass="native"/></id><propertyname="username"column="username"type="string"/><one-to-onename="address"class="Address"cascade="all"constrained="false"/></class><classname="Address"table="Address"><idname="id"column="id"><generatorclass="foreign"><paramname="property">person</param></generator></id><one-to-onename="person"class="Person"constrained="true"/><propertyname="addressName"column="addressName"type="string"/></class>
还是要自己一点一点写代码,然后编译,改错再编译好那。还有最重要的是.net的编译环境非常好,你甚是不需要了解太多工具,对于简单的系统,你可以之了解一些语法就哦了。 |
|