cancel
Showing results for 
Search instead for 
Did you mean: 

Data Model changes in OMS

Former Member
0 Kudos

Does anyone know how to extend some new attributes based on OOB OMS data model ? For example, the OOB "Inventory" data model in OMS. We would like to rename the "warehouse" to "Slave id", introduce additional column "Master Id". Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Mixins were introduced in Hybris-5.3.

But you should be also able to use the extends syntax. The disadvantage of it is that Existing parts of oms Do not know of your new type. But the underlying persistenceManager does and you can query as you described assuming that DummyOrderData is your extending ManagedObject.

Matthias

Former Member
0 Kudos

But I tried to use mixins. But no data file is getting generated with the new attribute. I need below line in oms-ext-domain.xml :

            <managedobject code="MyItemLocationData" extends="ItemLocationData" >
         <attributes>
             <attribute name="myAttribute" type="String">
                 <description>This is a dummy attribute.</description>
                 <modifiers unique="false" mandatory="false" final="true" indexed="true" />
             </attribute>
         </attributes>
     </managedobject>

 

What could be the reason?

Former Member
0 Kudos

Did you run mvn clean before generating the new MO? can you check the time stamp of your MO to make sure it was regenerated but without the mixin type.

Former Member
0 Kudos

when we are using extends that time the MO(MyItemLocationData) is generated but when using the mixin ,no code is getting generated.The following is the entry in oms-ext-domain.xml.

        <managedobject code="ItemLocationData" mixin="true">
         <attributes>
             <attribute name="priority" type="String" />
         </attributes>
     </managedobject>



No ItemLocationData.java file is generated in oms-ext-service project after doing mvn install.

Former Member
0 Kudos

not even the original one?

do you get any error or warning?

are your sure to use the same code in mixin which already exists?

Former Member
0 Kudos

No build error. You can check below link. Somebody else also got the same error. Check below link : https://answers.sap.com/questions/12752490/how-we-can-extend-managed-object-orderdata.html

So, Is it a version issue or I am missing something. i tried in different system buy without any luck.

Former Member
0 Kudos

Hi ,

In general I would not recommend to rename or delete anything in the data model as this could potentially lead to incompatibility with any existing usage. To introduce an additional attribute in the inventory data model just add a domain file defining a mixin managed object with the additional attribute. This additional attribute will be collected by the code generation and end up in an enhanced data model.

see: https://wiki.hybris.com/pages/viewpage.action?pageId=125184421#TypeSysteminCore%2B-MixinTypes

in order to avoid renaming I would suggest to either use default methods (JAVA8 only) on a non generated Entity or Traits in Java7 https://wiki.hybris.com/display/release5/Using+Traits+with+Managed+Objects

Hope this could help. Matthias

Former Member
0 Kudos

Thanks Matthias.

But I tried to do the same using "mixin". But the problem is no new generated code for this new attribute. I am using Hybris 3.0. Is "mixin" feature supported in Hybris 3.0 version ?

If not, then I have to use "extends" property like below :

But, how to access the new attribute "splitted". Will it be possible to query the table using DummyOrderData object? I mean like below : getPersistenceManager().createCriteriaQuery(DummyOrderData .class).resultList()

I tried this, but without any luck. It is returning blank list although there is data available in table.

Former Member
0 Kudos

Sorry, I missed to mention how I have used the "extends" property :

                  <description>The extension of OrderData</description>
                  <attributes>
                      <attribute name="splitted" type="boolean">
                      </attribute>
                  </attributes>