Actually half of the answer is in your question, Both Jalo and Dynamic attributes are used to create non-persisted attributes for items in Hybris.
But why do we need non-persisted attribute?
As you may know Items class in Hybris are generated using ant command so there is no way to add business logic manually to the item (because every time i run ant command a new item will be generated and my logic will be erased too)
I will give you an example :
//generated item
class PersonModel {
//persisted attributes
String firstname;
String lastName;
//non-persisted attribute = calculated attribute
String getFullName() {
return firstname + " " + lastname;
}
}
We all agree that fullName should not be persisted in the database, so let's assume that getFullName is added manually, then as i explained before if we run ant clean all command PersonModel will be re-generated again and getFullName() will be erased too.
So this what Jalo attribute created for, actually Jalo items are generated only once and will never be removed (it can be removed manually) so we can add all calculated attributes in Jalo item without fear of being erased.
//generated item is going to
//be re-generated after each ant clean all
class PersonModel {
//persisted attributes
String firstname;
String lastName;
}
//Jalo item will be generated once
//and will never be removed after that
class PersonJalo {
//non-persisted attribute = calculated attribute
String getFullName() {
return firstname + " " + lastname;
}
}
Jalo attribute is deprecated now and replaced by dynamic attribute, so we should never use jalo any more and use dynamic attribute instead.