-
-
Notifications
You must be signed in to change notification settings - Fork 3
3 items
| Tag |
|---|
3-items |
Things to consider when writing custom item types:
-
Avoid
nullattributes: If there is a sensible default value, use it and setoptional="false"(this is always valid for boolean attributes) -
It's usually not necessary to define the
jaloclass, let the platform generate that for you (packagerootfromextensioninfo.xml+.jalo.+<typecode>).
Commit this file! It is generated exactly once when a new type is introduced and the build never touches that file again. Committing the file avoids build errors when switching branches.PITFALL The exception to this rule is when you extend a abstract type, like
SimpleCMSComponent. Then you have to define thejaloClassotherwise your new type is also abstract. -
Always define a
<deployment>if the type extendsGenericItem, which it does by default -
If your new type extends a type that already defines a
<deployment>, do not add a new deployment for your new type. If you do so, the platform creates very poor SQL if you query for the supertype. -
Always define unique attributes + a unique database index
-
Heavily prefer
<relation>over<collectiontypes>. As a rule of thumb, only use collection types for dynamic attributes.
Technically the build still generates all item types for all extensions, but with this approach you at least avoid rebuilding the whole platform just because you tweaked the item types of a single extension.
cd hybris/bin/custom/extension
ant buildThis works in 95% of the cases, if something fails (the usual suspect is
GeneratedTypeInitializer.java ) use ant clean build
cd hybris/bin/platform
ant clean build
This will fail, because there will be some generated jalo classes are not automatically
deleted. To fix, delete the file that doesn't compile, usually the file is hybris/bin/custom/<extension>/src/.../jalo/<typecode>.java).
Unfortunately, the ...Model class for a custom type is generated into platform/bootstrap/gensrc,
and this folder is not cleaned / modified if you run the build in the extension folder.
This means to completely get rid of a type, you have to perform a platform
rebuild with ant clean build