Priyanka Gupta
Priyanka Gupta

Reputation: 359

String or java.lang.String and Boolean or java.lang.Boolean in items.xml in hybris

When we define java.lang.String or string and boolean or java.lang.Boolean as attribute type in items.xml in hybris.

Upvotes: 1

Views: 950

Answers (1)

Arvind Kumar Avinash
Arvind Kumar Avinash

Reputation: 79550

Since Hybris version 4, it is possible to use primitive Java types instead of the related wrapper classes e.g. boolean instead of java.lang.Boolean. The advantage of doing so is that the attribute definition gets a default value automatically. This removes the need for handling null values.

Thus, you can change the following definition

<attribute qualifier="myAttribute" type="java.lang.Boolean">
    <modifiers read="true" write="true" initial="true" optional="false"/>
    <persistence type="property"/>
</attribute>

into

<attribute qualifier="myAttribute" type="boolean">
    <modifiers read="true" write="true" initial="true" optional="false"/>
    <persistence type="property"/>
</attribute>

and perform the system update to make the change effective.

Upvotes: 1

Related Questions