我有 2 张桌子:
CREATE TABLE "LOCATION" (
"ID" NUMBER(19,0) NOT NULL ENABLE,
"VERSION" NUMBER(19,0) NOT NULL ENABLE,
"DELETEULD" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE,
"INBOUND" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE,
"AAENABLED" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE,
"WSUPLDTOOL" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE,
"CISDEST" VARCHAR2(7 CHAR),
"REVRECOVERY" NUMBER(1,0) DEFAULT 0,
CONSTRAINT "LOCATION_ID" PRIMARY KEY ("ID") ENABLE )
CREATE TABLE "TSLD164"."FTP_SCAN_EVENTS"
(
"HOSTNAME" VARCHAR2(200 BYTE),
"DIRECTORY" VARCHAR2(200 BYTE),
"USERNAME" VARCHAR2(20 BYTE),
"PASSWORD" VARCHAR2(20 BYTE),
"LOCATION_ID" NUMBER(19,0) NOT NULL ENABLE,
CONSTRAINT "FTP_SCAN_EVENTS_LOCATION_FK1" FOREIGN KEY ("LOCATION_ID") REFERENCES "LOCATION" ("ID") ENABLE
)
与 FK 和 PK 相关的表(Location_Id 列和 Id)
我有一个表格,上面所有的列都是字段。但是,表格中的列FTP_SCAN_EVENTS
是隐藏的,并且通过选择一个复选框(REVRECOVERY)
,它们会显示在表单中。并且用户可以根据需要动态添加行。
<td><form:checkbox path="revRecovery" onclick="showMe('div1',this), showMe('i1',this)"/>
<input type="hidden" value="1" name="_revRecovery"/>
FTP Scan Events</td></tr><tr><td colspan="4">
<table id="div1" style="display:none">
<tr><td><input type="text" value="hostname" onfocus="if(this.value == 'hostname'){this.value =''}" onblur="if(this.value == ''){this.value ='hostname'}" size="30" maxlength="200"/></td>
<td><input type="text" value="directory" onfocus="if(this.value == 'directory'){this.value =''}" onblur="if(this.value == ''){this.value ='directory'}" size="30" maxlength="200"/></td>
<td><input type="text" value="username" onfocus="if(this.value == 'username'){this.value =''}" onblur="if(this.value == ''){this.value ='username'}" size="20" maxlength="20"/></td>
<td><input type="text" value="password" onfocus="if(this.value == 'password'){this.value =''}" onblur="if(this.value == ''){this.value ='password'}" size="20" maxlength="20"/></td></tr>
</table>
</td></tr>
<tr id="i1" style="display:none"><td><input type="button" onclick="addRow()" value="+"/>
<input type="button" onclick="removeRowFromTable();" value="-" />
</td></tr>
我的位置的 hbm 文件:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="ca.ups.tundra.model">
<class name="Location" table="LOCATION">
<id name="id" access="field" type="long">
<generator class="native"/>
</id>
<version name="version" access="field" column="VERSION" type="long"/>
<property name="cisDest" type="string" column="CISDEST" length="7" not-null="true"/>
<property name="revRecovery" type="boolean" not-null="true"/>
<property name="deleteUld" type="boolean" not-null="true"/>
<property name="inbound" type="boolean" not-null="true"/>
<property name="aaEnabled" type="boolean" not-null="true"/>
<property name="wsUpldTool" type="boolean" not-null="true"/>
<property name="locationType" type="string" column="LOCATIONTYPE" length="2" not-null="true"/>
<set name="groups" table="LOCATIONGROUPS" cascade="save-update" access="field">
<key column="LOCATION_ID"/>
<many-to-many class="LocationGroup" column="GROUP_ID"/>
</set>
</class>
</hibernate-mapping>
Location 的模型类只是 setter 和 getter 方法。
我需要将我的第二个表映射到与上面相同的映射文件中,并且需要对 getter 和 setter 方法使用相同的模型类。