在 Hybris 项目中,我在 items.xml(从 GenericItem 扩展)中创建了新“自定义”实体。 经过ant clean all和ant initialize,所有的表都完美生成了,但是optional和unique修饰符没有' 对指定的属性有任何影响。 我的 items.xml 片段:
<attribute qualifier="someQualifier" type="java.lang.Long">
<description>some desctiontion</description>
<persistence type="property"/>
<modifiers optional="false" unique="true"/>
</attribute>
在我的数据库(在 MySQL 和 HSQL 上测试)中,可选和唯一标记属性仍然具有默认值(可空 = true,唯一 = false)。 这可能是什么问题?
最佳答案
这些修饰符是针对相应的 ValidateInterceptor 而不是针对表结构的。 要指定列定义,请使用:
<persistence type="property">
<columntype database="mysql">
<value>int(11) not null</value>
</columntype>
....
</persistence>
要使其唯一,请将索引定义添加到您的项目类型中
<indexes>
<index name="someQualifierIDX" unique="true">
<key attribute="someQualifier"/>
</index>
<indexes>
关于java - 属性修饰符不影响items.xml中的数据库,这是为什么呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42696613/