<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?
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);
}
}