Day 4: Composite Unique Keys in Hybris

--

You know until now I thought that composite unique keys are formed just by including unique=true for multiple attributes. My ignorance amazes me.

To define composite unique keys, we need to add new unique index in indexes element.

Consider this category table. Category code along with the catalogVersion makes the primary key.

<itemtype code="Category" 
generate="true"
jaloclass="de.hybris.platform.category.jalo.Category"
extends="GenericItem"
autocreate="true">
<deployment table="Categories" typecode="142"/>
............
...............
<indexes>
<index name="codeIDX" unique="false">
<key attribute="code"/>
</index>
<index name="versionIDX" unique="false">
<key attribute="catalogVersion"/>
</index>
<index name="codeVersionIDX" unique="true">
<key attribute="code"/>
<key attribute="catalogVersion"/>
</index>

</indexes>
</itemtype>

I have always felt proud about my data modeling knowledge. Now looking back, I shudder at my level of ignorance.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Priyanka Manikkoth
Priyanka Manikkoth

Written by Priyanka Manikkoth

Coder by occupation, dreamer by choice

No responses yet

Write a response