Hibernate 字段配置关系

根据业务需求在两张表中加了两个字段

做个总结:

column为实体中的字段名称 (基础表的字段)

name为自己指定的虚拟名称

Llt_Org_Info表中show_category字段与llt_system_code表中code字段配置关联关系

之前配置

<many-to-one name=" show_category " column="type" class="System_code" not-null="true"/>

错误1:column应为实体中的字段名称 (本想直接关联上llt_system_code表的type字段,测试后配置错误)

Llt_Org_Info 基础表中xml中增加配置

<property name="show_category" column="show_category" type="string" not-null="false" length="500" />

扫描二维码关注公众号,回复: 637642 查看本文章

<property name="recommend_flag" column="recommend_flag" type="string" not-null="false" length="1"/>

llt_system_code表中xml 配置

<id name="id" type="integer" column="id"><generator class="sequence"><param name="sequence">SEQ_LLT_SYSTEM_CODE</param></generator></id>

<property name="name" column="name" type="string" not-null="true" length="100"/>

<property name="code" column="code" type="string" not-null="true" length="10"/>

<property name="type" column="type" type="string" not-null="true" length="2"/>

hibernate中只需指定字段的基本信息hql查询时,就会根据表的id自带关联上其他属性将其引出

猜你喜欢

转载自ljl-java.iteye.com/blog/1774730
今日推荐