我在xml中有以下代码,我如何在下面的代码中使用注释
<hibernate-mapping>
<class name="com.gf.DataDetail" table="DATADETAIL">
<id name="DataId" type="java.lang.Long">
<column name="DATA_ID" />
<generator class="identity" />
</id>
<property name="recordId" type="java.lang.Long">
<column name="RECORD_ID" />
</property>
<property name="recordName" type="java.lang.String">
<column name="RECORD_NAME"></column>
</property>
<set name="detail" table="DETAIL"
inverse="true" lazy="true" fetch="select">
<key>
<column name="DATA_ID" not-null="true" />
</key>
<one-to-many class="com.gf.detail" />
</set>
<set name="loadErrors" table="LOADERRORS"
inverse="true" lazy="true" fetch="select">
<key>
<column name="DATA_ID" not-null="true" />
</key>
<one-to-many class="com.gf.loadErrors" />
</set>
</class>
在java文件中我有
@Entity
@Table(name = "DATADETAIL")
@JsonIgnoreProperties(ignoreUnknown = true)
public class BatchMetaData {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "DATA_ID")
private Number DATA_ID;
@Column(name = "RECORD_ID")
private Number RECORD_ID;
@Column(name = "RECORD_NAME")
private String RECORD_NAME;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "DATADETAIL")
private Set<DETAIL> detail =
new HashSet<DETAIL>(0);
@OneToMany(fetch = FetchType.LAZY, mappedBy = "DATADETAIL")
private Set<LOADERRORS> loadErrors =
new HashSet<LOADERRORS>(0);
public Set<DETAIL> getDetail() {
return detail;
}
public void setDetail(Set<DETAIL> detail) {
this.detail = detail;
}
public Set<LOADERRORS> getLoadErrors() {
return LoadErrors;
}
public void setLoadErrors(Set<LOADERRORS> LoadErrors) {
this.LoadErrors = LoadErrors;
}
我只是在这里从xml文件转换为注释文件。我在错误的地方应用oneto映射注释。对此提出了任何建议。
答案 0 :(得分:0)
这应该有效:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parent name")
mappedBy
应该是父对象名。