2017-03-09 51 views
0

在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)。 這裏有什麼問題?

+0

款Hybris似乎是一個SAP相關的公司。也許你的意思是Hibernate或其他ORM。 – RubioRic

+0

我的意思是Hybris作爲SAP相關的框架。 – sz3nt

+0

好的。我的錯。 – RubioRic

回答

3

這些修飾符用於相應的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> 
+0

謝謝!是否有任何可能的解決方案通過初始化來從items.xml(或任何其他地方)實現表結構,以使指定的屬性爲唯一或非空值? – sz3nt

+1

查看我更新的以前的答案。 – xl0e

相關問題