Deployment tag

When we talk about create an item is hybris means we are talking about to create a new data model (an object bluprint) One basis of that an object will be created who will be store in database.

But in the database where this object will save ?

Answer is : in the table and here is the scope of deployment tag will take place where each instance of object will be store. Actully we use deployment tag in hybris and by using this we defines the table information.

Basic sctucture of deployment tag and related information need to know :

<deployment table="CSCustomer" typecode="13000"/>
  • Here we can see component of deployment tag that is “table” and “typecode” and both should be unique globally.
  • We need to use value of the typecode must be a positive integer between greater than 10000 and less than 32767.
  • By Hybris Typecode values between 0 & 10000 are reserved so avoid to use value inbetween.
  • Always use a unique typecode value because it is used during the PK generation mechanism.

Best practice to use deployment for an item type :

Note : As we know, if we are creating any new custom item type and not extending any existing item type, then by default GenericItem will be considered a parent, so it's best practice to always use extends="GenericItem" as per Hybris Standard.

Scenario 1 : Creating new custom item type by extending GenericItem.

<itemtype code="ConsignmentEntry"
			jaloclass="de.hybris.platform.ordersplitting.jalo.ConsignmentEntry"
			extends="GenericItem" autocreate="true" generate="true">
			<deployment table="ConsignmentEntries" typecode="2004" />
			<attributes>
				<attribute qualifier="quantity" type="java.lang.Long">
					<modifiers read="true" write="true" optional="false" />
					<persistence type="property" />
				</attribute>
				<attribute qualifier="shippedQuantity" type="java.lang.Long">
					<modifiers read="true" write="true" optional="true" />
					<persistence type="property" />
				</attribute>
			</attributes>

		</itemtype>

Scenario 2 : Creating new custom item type by extending existing item type (existing item as an abstract).

 <itemtype code="AbstractMedia"
                  extends="GenericItem"
                  jaloclass="de.hybris.platform.jalo.media.AbstractMedia"
                  autocreate="true"
                  generate="true"
                  abstract="true">

   <itemtype code="DerivedMedia"
                  extends="AbstractMedia"
                  jaloclass="de.hybris.platform.jalo.media.DerivedMedia"
                  autocreate="true"
                  generate="true">
            <deployment table="DerivedMedias" typecode="31"/>

Note : In the Scenario 1 and 2 we must define deployment table other wise we will face build issue as below :

[ycheckdeployments] No deployment defined for relation <RELATIONNAME> in file: <FILENAME>

To overcome this default error we need to set the property build.development.mode to false in the local.properties file:
            build.development.mode=false
But we alwase escape to storing many item types in GenericItem. We need to define deployment to overcome the risk of performance and other related issue.

Scenario 3 : Creating new custom item type by extending existing item type (existing item has already defined deployment table).

<itemtype code="Product"
                  extends="GenericItem"
                  jaloclass="de.hybris.platform.jalo.product.Product"
                  autocreate="true"
                  generate="true">
            <deployment table="Products" typecode="1"/>

			<itemtype code="ApparelProduct" extends="Product"
				autocreate="true" generate="true" jaloclass="org.training.core.jalo.ApparelProduct">
				<description>Base apparel product extension that contains additional attributes.</description>
				<attributes>
					<attribute qualifier="genders" type="GenderList">
						<description>List of genders that the ApparelProduct is designed for</description>
						<modifiers />
						<persistence type="property" />
					</attribute>
				</attributes>
			</itemtype>

Note : As per Scenario 3 if we have already a deployment table for parent/super item then we should not define a new deployment (can be define but avoid) because this will decrease the performance of application. Because in this case when we need to fetch the data  then we need to use multiple joins in query.

Leave a comment