<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-563875556028449553</id><updated>2024-09-02T03:15:37.361-05:00</updated><title type='text'>El Blog  de Nelson Ortega</title><subtitle type='html'>Comercio electrónico, Tipos de Negocio, Modelos de ingresos, tecnología y más</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nelson-ortega.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/563875556028449553/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://nelson-ortega.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>nortegam</name><uri>http://www.blogger.com/profile/02383243716319766229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-563875556028449553.post-8357489451206495308</id><published>2017-06-12T16:13:00.001-05:00</published><updated>2017-06-12T16:25:29.335-05:00</updated><title type='text'>Hybris: How to set default values to new mandatory attributes on types with existing information </title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Hi guys,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Many times we have requirements to create a new mandatory attribute for an existing type. Most of the time we have already existing information for that type. And, how can we update this new mandatory attribute for those existing rows?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Well, we can do it easily with this&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial, helvetica, sans-serif;&quot;&gt;Impex&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial, helvetica, sans-serif;&quot;&gt;script :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;color: blue; wight: bold;&quot;&gt;&lt;b&gt;UPDATE&lt;/b&gt;&lt;/span&gt; &lt;span style=&quot;color: #38761d;&quot;&gt;Title&lt;/span&gt;[&lt;span style=&quot;color: #741b47;&quot;&gt;batchmode&lt;/span&gt;=true,&lt;span style=&quot;color: #741b47;&quot;&gt;impex.legacy.mod&lt;/span&gt;e=true]; 
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;code&lt;/span&gt;&lt;/span&gt;[&lt;span style=&quot;color: #741b47;&quot;&gt;unique&lt;/span&gt;=true,&lt;span style=&quot;color: #741b47;&quot;&gt;allownull&lt;/span&gt;=true];&lt;span style=&quot;color: #38761d;&quot;&gt;code&lt;/span&gt;
;;DefVal&lt;/pre&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Where in this case, there are some codes with null values for Title type and we want to update them with a default value &#39;DefVal&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;but, let&#39;s go in deep and see how it works.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;First, we are using two modifiers &#39;&lt;span style=&quot;color: #741b47;&quot;&gt;batchmode&lt;/span&gt;&#39; and &#39;&lt;span style=&quot;color: #741b47;&quot;&gt;impex.legacy.mode&lt;/span&gt;&#39;.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial, helvetica, sans-serif;&quot;&gt;The first one lets us update more than on row with one Impex line, in this case, we want to update all rows when the code is null to a default value. And the second one let us use the &#39;&lt;/span&gt;&lt;span style=&quot;color: #741b47; font-family: arial, helvetica, sans-serif;&quot;&gt;Allownull&lt;/span&gt;&lt;span style=&quot;font-family: arial, helvetica, sans-serif;&quot;&gt;&#39; modifier at attribute level.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Next, we need to tell hybris what is the base attribute to perform the update, I mean the where clause. It is identified with the unique modifier, and, cause it is mandatory and for that reason it don&#39;t accept null we need to add the &lt;span style=&quot;color: #741b47;&quot;&gt;allownull&lt;/span&gt; modifier. But way we need it null allower? In hybris if you don&#39;t specified a value for a column  explicitly hybris set it as null cause this is the default value and as we want to find all null codes we need this modifier.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Finally, we need an additional column&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial, helvetica, sans-serif;&quot;&gt;&#39;code&#39;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: arial, helvetica, sans-serif;&quot;&gt;to set the value that is going to replace all null field with our default value&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://nelson-ortega.blogspot.com/feeds/8357489451206495308/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nelson-ortega.blogspot.com/2017/06/hybris-how-to-set-default-values-to-new.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/563875556028449553/posts/default/8357489451206495308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/563875556028449553/posts/default/8357489451206495308'/><link rel='alternate' type='text/html' href='http://nelson-ortega.blogspot.com/2017/06/hybris-how-to-set-default-values-to-new.html' title='Hybris: How to set default values to new mandatory attributes on types with existing information '/><author><name>nortegam</name><uri>http://www.blogger.com/profile/02383243716319766229</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>