should be mapped with insert="false" update="false"的解决方法 和对象产生默认值的解决方法
2014-10-29 18:11
399 查看
问题 一 :Java web 开发的时候出现这个错误should be mapped with insert="false" update="false" 提示属性列添加insert="false" update="false" 就ok
出现问题的原因:多个属性对应一个属性列,如下所示:
<property name="companyCode" type="string">
<column name="公司编码" length="12" />
</property>
<many-to-one name="sealCompanyInfo" column="公司编码" class="com.zhuotai.app.entity.SealCompanyInfo" not-null="true"></many-to-one>
在网上查:删除一个就OK,可是我目前的需求是 既想保留属性列,有想保留实体关系配置,结果摸索了半天,终于找到了答案,哈哈哈,只怪自己太笨了,没有能及时的转换方法解决问题。接下来和大家分享下解决方法。如下:
<property name="companyCode" type="string">
<column name="公司编码" length="12" />
</property>
<many-to-one name="sealCompanyInfo" column="公司编码" class="com.zhuotai.app.entity.SealCompanyInfo" not-null="true"
insert="false" update="false"></many-to-one>
只要在实体关系配置中添加上insert="false" update="false"就OK.....看来我得好好学习hibernate了。。。。。。学习hibernate,走起。
问题二:没有为对象传任何值,但是调试的时候却出现了值,什么情况,嘿嘿,其实这个问题大家经常犯的
原因:在实体类中采用基本类型而不是对象
例如: 采用int 就会有默然值0 ,但是采用 Integer就不会出现了。谨记,谨记
出现问题的原因:多个属性对应一个属性列,如下所示:
<property name="companyCode" type="string">
<column name="公司编码" length="12" />
</property>
<many-to-one name="sealCompanyInfo" column="公司编码" class="com.zhuotai.app.entity.SealCompanyInfo" not-null="true"></many-to-one>
在网上查:删除一个就OK,可是我目前的需求是 既想保留属性列,有想保留实体关系配置,结果摸索了半天,终于找到了答案,哈哈哈,只怪自己太笨了,没有能及时的转换方法解决问题。接下来和大家分享下解决方法。如下:
<property name="companyCode" type="string">
<column name="公司编码" length="12" />
</property>
<many-to-one name="sealCompanyInfo" column="公司编码" class="com.zhuotai.app.entity.SealCompanyInfo" not-null="true"
insert="false" update="false"></many-to-one>
只要在实体关系配置中添加上insert="false" update="false"就OK.....看来我得好好学习hibernate了。。。。。。学习hibernate,走起。
问题二:没有为对象传任何值,但是调试的时候却出现了值,什么情况,嘿嘿,其实这个问题大家经常犯的
原因:在实体类中采用基本类型而不是对象
例如: 采用int 就会有默然值0 ,但是采用 Integer就不会出现了。谨记,谨记
相关文章推荐
- 出现should be mapped with insert="false" update="false"的解决方法
- Hibernate_should be mapped with insert="false" update="false"的解决方法
- 出现should be mapped with insert="false" update="false"的解决方法
- 出现should be mapped with insert="false" update="false"的解决方法
- should be mapped with insert="false" update="false"
- 玩转JPA(一)---异常:Repeated column in mapping for entity/should be mapped with insert="false" update="fal
- Repeated column in mapping for entity:should be mapped with insert="false" update="false"
- column: xxxxxx_ID (should be mapped with insert="false" update="false")
- Repeated column in mapping for entity: .... should be mapped with insert="false" update="false"
- Repeated column in mapping for entity:(should be mapped with insert="false" update="false")
- hibernate column should be mapped with insert="false" update="false" 错误原因
- Repeated column in mapping for entity:(should be mapped with insert="false" update="false")
- should be mapped with insert="false" update="false" 解决办法
- msg_cp (should be mapped with insert="false" update="false")
- should be mapped with insert="false" update="false
- 玩转JPA(一)---异常:Repeated column in mapping for entity/should be mapped with insert="false" update="fal
- JPA-hibernate注解之 should be mapped with insert="false" update="false"
- should be mapped with insert="false" update="false"
- should be mapped with insert="false" update="false"
- Hibernate中should be mapped with insert="false" update="false"错误