Data Modeling in SAP Commerce(Hybris)

  1. Item types − used to create tables.
  2. Relation types − used to create relation between tables.
  3. Atomic types − used to create various Atomic types.
  4. Collection types − used to create Collections.
  5. Map Types − used to define maps.
  6. Enum types − used to define Enums.

Item Types

<itemtype code="Customer"
extends="User"
jaloclass="de.hybris.platform.jalo.user.Customer"
autocreate="true"
generate="true">
<attributes>
<!-- auto ID which is generated by NumberSeries -->
<attribute autocreate="true" qualifier="customerID" type="java.lang.String">
<modifiers read="true" write="true" search="true" optional="true"/>
<persistence type="property"/>
</attribute>
</attributes>

</itemtype>

1) Define the new item type without extending any existing item type

<itemtype code="PickupPlant" autocreate="true" generate="true" jaloclass="com.custom.core.jalo.PickupPlant">
<description>Pickup Plants</description>
<deployment table="PickupPlant" typecode="30044" />
<attributes>
<attribute qualifier="name" type="localized:java.lang.String" >
<description>Split order name.</description>
<persistence type="property" />
<modifiers read="true" write="true" />
</attribute>
<attribute qualifier="plantId" type="localized:java.lang.String" >
<description>Plant SAP Code</description>
<persistence type="property" />
<modifiers read="true" write="true" />
</attribute>
</attributes>
</itemtype>
  • generate=true — this way Java class files will be generated for this type. Setting the generate modifier to false results in no Java class file being generated for this type. We should set it to true for the first definition of item type.
  • autocreate=true — indicates that PickupPlant is a new type and new database entry for this type will be created. We should set it to true for the first definition of item type.
  • deplyoment table modifier: is to pecifies the table where the instances of the item type are stored.
  • typecode modifier: is used internally to create item PKs. Using typcode which already exists will cause failure. Typecode values between 0 and 10000 are reserved for hybris internal use, typecode values greater than 10000 can be used — between 0 & 32767.
  • read = true — means attribute is readable and getter method will be generated for the attribute. If false, we cannot access it from our java program;
  • write=true — means attribute is writable and setter method will be generated for the attribute. If false, we cannot modify the value;
  • optional=true — if false, it is mandatory to initialize this attribute. To make attribute not mandatory make it true;
  • search — if true, the attribute is searchable through FlexibleSearch queries;
  • unique– if true, the attribute must hold a unique value. Similar to unique constraints in DBMS.

2) Define the new item type by extending it with existing item type

<itemtype code="SubCart" extends="Cart" jaloclass="com.custom.core.jalo.order.CchSubCart">
<attributes>
<attribute qualifier="cartId" type="java.lang.String">
<persistence type="property"/>
<modifiers read="true" write="true" optional="false"/>
</attribute>
</attributes>

</itemtype>

3) Define the existing item type again with new attributes

<itemtype code="BaseStore" autocreate="false" generate="false">
<description>Extending BaseStore for usecases</description>
<attributes>
<attribute qualifier="showCreditInformation" type="boolean">
<description>Show or hide user creditinformation</description>
<persistence type="property" />
<defaultvalue>true</defaultvalue>
</attribute>

</attributes>
</itemtype>

Atomic Types

<atomictypes>
<atomictype class="java.lang.Object" autocreate="true" generate="false"/>
<atomictype class="java.lang.Number" extends="java.lang.Object" autocreate="true" generate="false"/>
<atomictype class="java.lang.Integer" extends="java.lang.Number" autocreate="true" generate="false"/>
<atomictype class="java.lang.Boolean" extends="java.lang.Object" autocreate="true" generate="false"/>
<atomictype class="java.lang.Byte" extends="java.lang.Number" autocreate="true" generate="false"/>
<atomictype class="java.lang.Double" extends="java.lang.Number" autocreate="true" generate="false"/>
<atomictype class="java.lang.Float" extends="java.lang.Number" autocreate="true" generate="false"/>
...........
</atomictypes>

Collection Types

<collectiontypes>
<collectiontype code="ExampleCollection" elementtype="Item" autocreate="true" generate="false"/>
<collectiontype code="ItemCollection" elementtype="Item" autocreate="true" generate="false"/>
<collectiontype code="StringCollection" elementtype="java.lang.String" autocreate="true" generate="false"/>
<collectiontype code="ObjectCollection" elementtype="java.lang.Object" autocreate="true" generate="false"/>
<collectiontype code="MediaCollection" elementtype="Media" autocreate="true" generate="true"/>
<collectiontype code="AbstractOrderEntryList" elementtype="AbstractOrderEntry" autocreate="true"
generate="false"
type="list"/>
<collectiontype code="CartEntryCollection" elementtype="CartEntry" autocreate="true" generate="false"
type="list"/>
<collectiontype code="OrderEntryCollection" elementtype="OrderEntry" autocreate="true" generate="false"
type="list"/>
<collectiontype code="QuoteEntryCollection" elementtype="QuoteEntry" autocreate="true" generate="false"
type="list"/>
<collectiontype code="RegionCollection" elementtype="Region" autocreate="true" generate="false"/>
<collectiontype code="LanguageCollection" elementtype="Language" autocreate="true" generate="true"/>
<collectiontype code="LanguageList" elementtype="Language" autocreate="true" generate="true" type="list"/>
<collectiontype code="LanguageSet" elementtype="Language" autocreate="true" generate="true" type="set"/>
<collectiontype code="ViewAttributeList" elementtype="ViewAttributeDescriptor" autocreate="true"
generate="false"
type="list"/>
<collectiontype code="ViewAttributeSet" elementtype="ViewAttributeDescriptor" autocreate="true" generate="false"
type="set"/>
<collectiontype code="configAttributeSet" elementtype="ConfigAttributeDescriptor" autocreate="true"
generate="false"/>
<collectiontype code="subTypesSet" elementtype="ComposedType" autocreate="true" generate="false"/>
<collectiontype code="AtomicTypeSubtypeCollection" elementtype="AtomicType" autocreate="true" generate="false"/>
<collectiontype code="RestrictionList" elementtype="SearchRestriction" autocreate="true" generate="false"/>
...................
</collectiontypes>

Map Types

<maptypes>
<maptype code="ExampleMap"
argumenttype="Language"
returntype="java.math.BigInteger"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.String"
argumenttype="Language"
returntype="java.lang.String"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.Integer"
argumenttype="Language"
returntype="java.lang.Integer"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.Boolean"
argumenttype="Language"
returntype="java.lang.Boolean"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.Double"
argumenttype="Language"
returntype="java.lang.Double"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.Float"
argumenttype="Language"
returntype="java.lang.Float"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.Long"
argumenttype="Language"
returntype="java.lang.Long"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.Short"
argumenttype="Language"
returntype="java.lang.Short"
autocreate="true"
generate="false"/>
<maptype code="localized:java.lang.Character"
argumenttype="Language"
returntype="java.lang.Character"
autocreate="true"
generate="false"/>
<maptype code="localized:java.util.Date"
argumenttype="Language"
returntype="java.util.Date"
autocreate="true"
generate="false"/>
.........
</maptypes>

Enum Types

<enumtypes>
<enumtype code="TestEnum">
<value code="testValue1"/>
<value code="testValue2"/>
<value code="testValue3"/>
<value code="testValue4"/>
</enumtype>
<enumtype code="EncodingEnum" autocreate="true" generate="true" dynamic="true"/>
<!-- order -->
<enumtype code="CreditCardType" autocreate="true" generate="true">
<value code="amex"/>
<value code="visa"/>
<value code="master"/>
<value code ="diners"/>
</enumtype>
<enumtype code="RelationEndCardinalityEnum" autocreate="true" generate="true">
<value code="one"/>
<value code="many"/>
</enumtype>
<enumtype code="MediaManagementTypeEnum" autocreate="true" generate="true">
<value code="FILES"/>
<value code="SSH"/>
<value code="FTP"/>
</enumtype>
<!-- hmc legacy - Saved Values -->
<enumtype code="SavedValueEntryType" autocreate="true" generate="true">
<value code="created"/>
<value code="removed"/>
<value code="changed"/>
</enumtype>
<enumtype code="PhoneContactInfoType" generate="true" autocreate="true" dynamic="true">
<description>Phone type</description>
<value code="MOBILE"/>
<value code="WORK"/>
<value code="HOME"/>
</enumtype>
<!-- quote -->
<enumtype code="QuoteState" autocreate="true" generate="true" dynamic="true">
<value code="CREATED"/>
<value code ="DRAFT"/>
<value code="SUBMITTED"/>
<value code="OFFER"/>
<value code="ORDERED"/>
<value code="CANCELLED"/>
<value code="EXPIRED"/>
</enumtype>
............
</enumtypes>

Relation Types

<relations>        <relation code="PrincipalGroupRelation" autocreate="true" generate="false" localized="false"
deployment="de.hybris.platform.persistence.link.PrincipalGroupRelation">
<sourceElement qualifier="members" type="Principal" collectiontype="set" cardinality="many" ordered="false">
<modifiers read="true" write="true" search="true" optional="true"/>
</sourceElement>
<targetElement qualifier="groups" type="PrincipalGroup" collectiontype="set" cardinality="many"
ordered="false">
<modifiers read="true" write="true" search="true" optional="true"/>
</targetElement>
</relation>
<!-- MediaContainer stuff PLA-5950 -->
<relation code="MediaContainer2MediaRel" localized="false" generate="true" autocreate="true">
<sourceElement type="MediaContainer" qualifier="mediaContainer" cardinality="one">
<modifiers read="true" write="true" search="true" optional="true"/>
</sourceElement>
<targetElement type="Media" qualifier="medias" cardinality="many">
<modifiers read="true" write="true" search="true" optional="true"/>
</targetElement>
</relation>
<relation code="MediaContext2MediaFormatMappingRel" localized="false" generate="true" autocreate="true">
<sourceElement type="MediaContext" qualifier="mediaContext" cardinality="one">
<modifiers read="true" write="true" search="true" optional="false" unique="true"/>
</sourceElement>
<targetElement type="MediaFormatMapping" qualifier="mappings" cardinality="many">
<modifiers read="true" write="true" search="true" optional="true" partof="true"/>
</targetElement>
</relation>
<relation code="Media2DerivedMediaRel" localized="false" generate="true" autocreate="true">
<sourceElement type="Media" qualifier="media" cardinality="one">
<modifiers read="true" write="true" search="true" optional="false"/>
</sourceElement>
<targetElement type="DerivedMedia" qualifier="derivedMedias" cardinality="many">
<modifiers read="true" write="true" search="true" optional="true" partof="true"/>
</targetElement>
</relation>

<relation code="User2Orders" generate="true" localized="false" autocreate="true">
<sourceElement type="User" cardinality="one" qualifier="user">
<modifiers read="true" write="true" search="true" optional="false"/>
</sourceElement>
<targetElement type="Order" cardinality="many" qualifier="orders">
<modifiers read="true" write="true" search="true" optional="true" partof="true"/>
</targetElement>
</relation>
</relations>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store