使用公式插入字段(休眠)
Insert field with formula (hibernate)
我需要在插入对象之前设置另一个 select 中的一个字段。
我创建 属性 喜欢:
<property name="measureIndex" not-null="false" type="integer">
<formula>(SELECT MAX(measure.measureIndex)+1 from measure WHERE measure.schemaId = schemaId)</formula>
<column name="measureIndex" default="1" />
</property>
但已抛出错误 - 嵌套异常是:org.hibernate.MappingException: property mapping has wrong number of columns: com.dataswell.core.domain.api.Measure.measureIndex type: integer
然后尝试:
<property name="measureIndex" not-null="false" type="integer">
<formula>(SELECT IFNULL(MAX(measure.measureIndex),0)+1 from measure WHERE measure.schemaId = schemaId)</formula>
</property>
我需要在插入对象之前设置另一个 select 中的一个字段。
我创建 属性 喜欢:
<property name="measureIndex" not-null="false" type="integer">
<formula>(SELECT MAX(measure.measureIndex)+1 from measure WHERE measure.schemaId = schemaId)</formula>
<column name="measureIndex" default="1" />
</property>
但已抛出错误 - 嵌套异常是:org.hibernate.MappingException: property mapping has wrong number of columns: com.dataswell.core.domain.api.Measure.measureIndex type: integer
然后尝试:
<property name="measureIndex" not-null="false" type="integer">
<formula>(SELECT IFNULL(MAX(measure.measureIndex),0)+1 from measure WHERE measure.schemaId = schemaId)</formula>
</property>