Difference between relations and collections type in hybris?

1.what is collection type and relation type ?
2.when to use collection and when to use relation type in hybris ???
3.summary

1.what is collection type and relation type ?
CollectionTypes are based on Java Collection class we can use List , Set here.
In the database the collection type stores the data in one column as the list of PKs.
here there is limit for this because it stores this as a string.

However when we do the relation there is no limit because it uses the traditional RDBMS foreign key concept to create relation between types.

Though collection type is faster than the relation type it only provides unidirectional relationships i.e. one – to -many or many- to – one

2.when to use collection and when to use relation type in hybris ???
we can use collection type when we expect the fast retrieval and when we know that the size of data to be store in relation
Eg : customer — address ( one customer can have more than one address ) here we know that the customer address will not be more that 3 or 4.

Hybris discourage use of collection type as it has constrain on the number of elements to be added.

we can use relation in one-to-many and many-to-one scenarios.

3. summary
We can use collection type when we know size of size of collection is limited .But use of Collection type is discouraged  by hybris .

Reference:
https://wiki.hybris.com/display/release5/Type+System+Documentation#TypeSystemDocumentation-CollectionTypes

Leave a Reply

Your email address will not be published. Required fields are marked *