SAP Hybris suite , Hybris tutorial, Java, J2ee Stuff Online-

0
Core concept of autocreate and generate in hybris items | items concept in hybris ?

Open 2 Answers 2496 Views

Clear Concept about autocreate and generate in Hybris item

In many time hybris developer become confuse or not able to give clear answer related autocreate and generate in hybris item.so today i have decided to go with autocreate and generate

I know every hybris developer who started reading this post they will think that i know but lets cheack your concept with my scenario

1. what meaning of autocreate and generate
  Answer : as per hybris wiki autocreate means make database entry during initialization and update for this item and generate is responsible to create generated java class and jalo class

2. So my second question is what is meaning of database entry for autocreate
    suppose your item is
             

  <itemtype code="EveryreplyCustTest2" generate="false" autocreate="false">
                   <description>It represents everyreply Customer.</description>
                   <attributes>
                       <attribute qualifier="customerId" type="java.lang.String" >
                    <persistence type="property" />
                   <description>It is localized customerId of the everyreply user.</description>
                 </attribute>
                  </attributes>
    </itemtype>    

If you given autocreate="false" then it will give Build error means you are restricting to create model class then there is no any meaning of this item in hybris because defining items means data model then

 Why it autocreate given in Hybris while must have to create model class?
              

Because sometime you extending Items then at time you are doing something on extisting model class then there is not require to create model class again so thats why Hybris given attribute autocreate on Item definition level

Now again autocreate comes under to define attribute level also as below

               

 <attributes>
                    <attribute qualifier="customerId" type="java.lang.String" autocreate="true">
                       <persistence type="property" />
                       <description>It is localized customerId of the everyreply user.</description>
 </attribute>

 

In above autocreate follow same rule as Item level definition but for this it will follow rule inside your Model class if it is false then this attribute will missing in your model class

3. Now comes to use Generate in Items level and Attribute definition level
Generate is responsible to create jalo class and generated class in extension . If you given generate="false" then after build there will create jalo class and generated class in your extension.
   
 

  <itemtype code="EveryreplyUserTest1"  autocreate="true" generate="false" >
                <description>Apparel size variant type that contains additional attribute describing variant size.</description>
                <attributes>
                <attribute qualifier="userid" type="java.lang.String">
                        <description>Size of the product.</description>
                        <modifiers initial="true" write="false"/>
                        <persistence type="property"/>
                    </attribute>
                </attributes>
            </itemtype>

if you given generate="false" and given jaloclass as below

 

<itemtype code="EveryreplyUserTest1"  autocreate="true" generate="false" jaloclass="de.hybris.platform.yacceleratorcore.jalo.EveryreplyUserTest1" >
                <description>Apparel size variant type that contains additional attribute describing variant size.</description>
                <attributes>
                <attribute qualifier="userid" type="java.lang.String">
                        <description>Size of the product.</description>
                        <modifiers initial="true" write="false"/>
                        <persistence type="property"/>
                    </attribute>
                </attributes>
            </itemtype>
 

 

Then it give build error

In attribute level Generate="true" is responsible for creating setter and getter inside the model class. as you there another modifier used in attribute
   <modifiers write="true"  read="true"/>

it is responsible for creating setter and getter inside the model class then definetly in your mind question is coming that why used generate while read and write is responsible for setter and getter so below combination will make you ok

   a. generate="false" and in modifier read="true" write="true"  > build error
   b. generate="true" and in modifier read="false" write="true"  > only setter will create
   c. generate="true" and in modifier read="true"  write="false" > only getter is create
 

2 Answers

0
answered Apr 4 by anonymous
0

Where is your answer for second question?

question:So my second question is what is meaning of database entry for autocreate?

answered Sep 12 by anonymous

...