Reputation: 37
<itemtype code="IntegrationSystemCredentials" autocreate="true" generate="true">
<deployment **table**="IntegrationSystemCredentials" typecode="11000" />
</itemtype>
In the above code i have mentioned deployment table and typecode. why we are using both?
Upvotes: 2
Views: 4043
Reputation: 5810
what is the deployment table in hybris?
Items within SAP Commerce are made persistent by writing values into a database. Within the database, the values are stored in tables. SAP Commerce allows you to explicitly define the database tables where the values of instances of a given type will be written. This can be done by defining the deployment tag.
Like.
<deployment table="mytype_deployment" typecode="12345" />
When to define the deployment table?
One should define the deployment table for an item type when
Your item type doesn't extend any other item type (except GenericItem, which is by default)
Your item type extend existing item type for which there is no deployment table defined
Read more Specifying a Deployment for Platform Types
Upvotes: 0
Reputation: 78945
In the above code i have mentioned deployment table and typecode. why we are using both?
The short answer is: It's because they serve different purposes.
deployment table
Using deployment table
, you map a database table to the itemtype
. If you do not mention deployment table
, the values of the attributes of the itemtype
will be saved into the deployment table
of its parent itemtype
; in other words, in absence of the deployment table
in the itemtype
definition, the database table of the patent itemtype
will be mapped with the itemtype
.
If you are creating an itemtype
by extending GenericItem
, you must declare a deployment table
(a mechanism to avoid the attributes of the itemtype
getting saved in GenericItem
table). However, if you are extending some other itemtype
e.g. Product
, you should avoid declaring deployment table
as much as possible in order to avoid too many joins required during the execution of the Flexible Search Query.
Note that GenericItem
is the default parent of an itemtype
i.e. if you do not declare extends...
in the itemtype
definition, the itemtype
will, by default, extend GenericItem
e.g. the following itemtype
definition will fail compilation because DummyItem
extends GenericItem
by default but there is no deployment table
mentioned for it.
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="items.xsd">
<itemtypes>
<itemtype code="DummyItem" autocreate="true">
<attributes>
<attribute qualifier="uname" type="java.lang.String">
<modifiers read="true" write="true" search="true" initial="true" optional="false"/>
<defaultvalue>"Hello"</defaultvalue>
<persistence type="property"></persistence>
</attribute>
</attributes>
</itemtype>
</itemtypes>
</items>
typecode
The typecode
attribute is a unique number to reference the type. The value of the typecode attribute must be a positive integer between 0
and 32767 (2^15-1)
and must be unique throughout your hybris application as it is part of the PK
generation mechanism as shown below:
private static PK createPK_Counter(int typecode, long counter) {
if (typecode >= 0 && typecode <= 32767) {
//...
} else {
throw new IllegalArgumentException("illegal typecode : " + typecode + ", allowed range: 0-" + 32767);
}
}
Check this and this to learn more about it.
Upvotes: 2