<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Relation one to many between hybris type and enum in CRM and CX Q&amp;A</title>
    <link>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaa-p/11991524#M357715</link>
    <description>&lt;P&gt;Hello.
You should use many-to-many relation here.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;         &amp;lt;relation code="ProdToLitterTypeRel" localized="false"&amp;gt;
             &amp;lt;description&amp;gt;...&amp;lt;/description&amp;gt;
             &amp;lt;deployment table="deployment_name" typecode="10050"/&amp;gt;
             &amp;lt;sourceElement type="Product" cardinality="many" navigable="false"/&amp;gt;
             &amp;lt;targetElement type="LitterType" qualifier="litterTypes" cardinality="many"/&amp;gt;
         &amp;lt;/relation&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, there is no need to specify litterType  in Product itemtype 
&lt;/P&gt;</description>
    <pubDate>Wed, 28 Sep 2016 11:09:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2016-09-28T11:09:56Z</dc:date>
    <item>
      <title>Relation one to many between hybris type and enum</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaq-p/11991523</link>
      <description>&lt;P&gt;My goal is to allow products (hybris item) to have multiple values of litterType (enum) assigned.&lt;/P&gt;
&lt;P&gt;In order to achieve that, in my *-items.xml file I have declared:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;     &amp;lt;enumtype generate="true" code="LitterType" dynamic="true" autocreate="true"&amp;gt;
         &amp;lt;value code="ANTI_BACTERIAL" /&amp;gt;
         &amp;lt;value code="UNSCENTED" /&amp;gt;
     &amp;lt;/enumtype&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt; .................................&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;     &amp;lt;relation code="ProdToLitterTypeRel" localized="false" generate="true" autocreate="true"&amp;gt;
         &amp;lt;description&amp;gt;Relation between product and litter type&amp;lt;/description&amp;gt;
         &amp;lt;sourceElement type="Product" qualifier="product" cardinality="one"&amp;gt;
             &amp;lt;description&amp;gt;Product&amp;lt;/description&amp;gt;
             &amp;lt;modifiers read="true" write="true" search="true" optional="true"/&amp;gt;
         &amp;lt;/sourceElement&amp;gt;
         &amp;lt;targetElement type="LitterType" qualifier="litterType" cardinality="many"&amp;gt;
             &amp;lt;description&amp;gt;Litter type&amp;lt;/description&amp;gt;
             &amp;lt;modifiers read="true" write="true" search="true" optional="true" partof="false"/&amp;gt;
         &amp;lt;/targetElement&amp;gt;
     &amp;lt;/relation&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;............................................&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;             &amp;lt;itemtype code="Product" autocreate="false" generate="true"&amp;gt;
                 &amp;lt;description&amp;gt;Base product&amp;lt;/description&amp;gt;
                 &amp;lt;attributes&amp;gt;
                     &amp;lt;attribute type="localized:java.lang.String" qualifier="VMNo"&amp;gt;
                         &amp;lt;modifiers read="true" write="true" /&amp;gt;
                         &amp;lt;persistence type="property" /&amp;gt;
                         &amp;lt;description&amp;gt;VMD Product Information.&amp;lt;/description&amp;gt;
                     &amp;lt;/attribute&amp;gt;
                     &amp;lt;attribute type="LitterType" qualifier="litterType"&amp;gt;
                         &amp;lt;persistence type="property" /&amp;gt;
                         &amp;lt;modifiers read="true" write="true" /&amp;gt;
                         &amp;lt;description&amp;gt;Litter type&amp;lt;/description&amp;gt;
                     &amp;lt;/attribute&amp;gt;
                 &amp;lt;/attributes&amp;gt;
             &amp;lt;/itemtype&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Unfortunately the relation "ProdToLitterTypeRel" is throwing an exception when I try to build the project:&lt;/P&gt;
&lt;P&gt;java.lang.ClassCastException: de.hybris.bootstrap.typesystem.YEnumType cannot be cast to de.hybris.bootstrap.typesystem.YCollectionType
    at de.hybris.bootstrap.codegenerator.jalo.RemoveFromRelation.getRelatedType(RemoveFromRelation.java:33)
    at de.hybris.bootstrap.codegenerator.jalo.AddToRelation.(AddToRelation.java:32)
    at de.hybris.bootstrap.codegenerator.jalo.ItemTypeWriter.createAddToRelation(ItemTypeWriter.java:157)&lt;/P&gt;
&lt;P&gt;Is possible to create a one to many relation between hybris item and enum? In case it is not possible, what would be the best approach to achieve my goal?
&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 10:39:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaq-p/11991523</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-09-28T10:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Relation one to many between hybris type and enum</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaa-p/11991524#M357715</link>
      <description>&lt;P&gt;Hello.
You should use many-to-many relation here.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;         &amp;lt;relation code="ProdToLitterTypeRel" localized="false"&amp;gt;
             &amp;lt;description&amp;gt;...&amp;lt;/description&amp;gt;
             &amp;lt;deployment table="deployment_name" typecode="10050"/&amp;gt;
             &amp;lt;sourceElement type="Product" cardinality="many" navigable="false"/&amp;gt;
             &amp;lt;targetElement type="LitterType" qualifier="litterTypes" cardinality="many"/&amp;gt;
         &amp;lt;/relation&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, there is no need to specify litterType  in Product itemtype 
&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 11:09:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaa-p/11991524#M357715</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-09-28T11:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Relation one to many between hybris type and enum</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaa-p/11991525#M357716</link>
      <description>&lt;P&gt;Hi, unfortunately changing the relation to many to many didn't fix the problem. I continue having the same exception
&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 11:25:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaa-p/11991525#M357716</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-09-28T11:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Relation one to many between hybris type and enum</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaa-p/11991526#M357717</link>
      <description>&lt;P&gt;I found a solution, instead of using a relation we need to use a collection type:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; &amp;lt;collectiontypes&amp;gt;        
 &amp;lt;collectiontype code="LitterTypeList" elementtype="LitterType" type="list" autocreate="true" generate="false"/&amp;gt;
     &amp;lt;/collectiontypes&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use the collection in the product attribute:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; &amp;lt;attribute type="LitterTypeList" qualifier="litterTypeList"&amp;gt;
                          &amp;lt;persistence type="property" /&amp;gt;
                          &amp;lt;modifiers read="true" write="true" /&amp;gt;
                          &amp;lt;description&amp;gt;Litter type&amp;lt;/description&amp;gt;
                      &amp;lt;/attribute&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2016 13:07:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/relation-one-to-many-between-hybris-type-and-enum/qaa-p/11991526#M357717</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-09-28T13:07:44Z</dc:date>
    </item>
  </channel>
</rss>

