属性的修饰符不会影响items.xml中的数据库,为什么?
问题描述:
在Hybris项目中,我创建了新“自定义”实体在items.xml(从GenericItem扩展)。 蚂蚁蚂蚁干净初始化毕竟和,所有的表都完美地产生,但可选和独特的修饰没有在指定属性的任何影响。 我items.xml的一个片段:属性的修饰符不会影响items.xml中的数据库,为什么?
<attribute qualifier="someQualifier" type="java.lang.Long">
<description>some desctiontion</description>
<persistence type="property"/>
<modifiers optional="false" unique="true"/>
</attribute>
我的数据库中可选的和独特的标记属性(在MySQL和HSQL测试)仍然有默认值(可为空=真,唯一= 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>
款Hybris似乎是一个SAP相关的公司。也许你的意思是Hibernate或其他ORM。 – RubioRic
我的意思是Hybris作为SAP相关的框架。 – sz3nt
好的。我的错。 – RubioRic