<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aleksandr</title>
    <description>The latest articles on DEV Community by Aleksandr (@xterm).</description>
    <link>https://dev.to/xterm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F238834%2Fa1c33a6f-6e64-46bd-8a4e-bfa4ee36d7e7.JPG</url>
      <title>DEV Community: Aleksandr</title>
      <link>https://dev.to/xterm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xterm"/>
    <language>en</language>
    <item>
      <title>Be careful when using @Configuration classes with @EnableWebMvc in Spring Boot</title>
      <dc:creator>Aleksandr</dc:creator>
      <pubDate>Wed, 26 Apr 2023 08:21:43 +0000</pubDate>
      <link>https://dev.to/xterm/be-careful-when-using-configuration-classes-with-enablewebmvc-in-spring-boot-2n32</link>
      <guid>https://dev.to/xterm/be-careful-when-using-configuration-classes-with-enablewebmvc-in-spring-boot-2n32</guid>
      <description>&lt;h3&gt;
  
  
  Situation
&lt;/h3&gt;

&lt;p&gt;Recently, we have been faced with a strange issue after adding a configuration class to our Spring Boot application. Unfortunately, the logs didn't provide any valuable information, becuause we didn't use the bean in our new configuration class which mention in logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Parameter 1 of constructor in com.xyz.spring.starter.web.filter.FilterAutoConfiguration required a bean of type 'org.springframework.web.filter.RequestContextFilter' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.web.filter.RequestContextFilter' in your configuration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And our new configuration class looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="nd"&gt;@EnableWebMvc&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;WebConfiguration&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;WebMvcConfigurer&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// some simple logic&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After playing with the configuration, we found out that using the &lt;strong&gt;@EnableWebMvc&lt;/strong&gt; annotation breaks our project. So, let's go deeper into the Spring configuration to understand why this is happening.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the @Configuration annotation?
&lt;/h3&gt;

&lt;p&gt;The Spring Framework documentation says: the &lt;strong&gt;@Configuration&lt;/strong&gt; annotation allows us to use annotations for dependency injection. This annotation tels Spring that a class has some methods which create beans that can be used in the application. When the Spring container detects this annotation, it process this class and create these beans.&lt;/p&gt;

&lt;p&gt;Just an example of using the @Configuration annotation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppConfig&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Bean&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;MyBean&lt;/span&gt; &lt;span class="nf"&gt;myBean&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// instantiate, configure and return bean ...&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is the @EnableWebMvc annotation?
&lt;/h3&gt;

&lt;p&gt;The official documentation says:&lt;br&gt;
Adding this annotation to an &lt;strong&gt;@Configuration&lt;/strong&gt; class imports the Spring MVC configuration from &lt;strong&gt;WebMvcConfigurationSupport&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="nd"&gt;@EnableWebMvc&lt;/span&gt;
&lt;span class="nd"&gt;@ComponentScan&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basePackageClasses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MyConfiguration&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyConfiguration&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To customize the imported configuration, implement the interface &lt;strong&gt;WebMvcConfigurer&lt;/strong&gt; and override individual methods, e.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="nd"&gt;@EnableWebMvc&lt;/span&gt;
&lt;span class="nd"&gt;@ComponentScan&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basePackageClasses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MyConfiguration&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyConfiguration&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;WebMvcConfigurer&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;addFormatters&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;FormatterRegistry&lt;/span&gt; &lt;span class="n"&gt;formatterRegistry&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;formatterRegistry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;addConverter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MyConverter&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;configureMessageConverters&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HttpMessageConverter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;?&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;converters&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;converters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MyHttpMessageConverter&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And there is some very interresting point:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; only one &lt;strong&gt;@Configuration&lt;/strong&gt; class may have the &lt;strong&gt;@EnableWebMvc&lt;/strong&gt; annotation to import the Spring Web MVC configuration. There can however be multiple &lt;strong&gt;@Configuration&lt;/strong&gt; classes implementing WebMvcConfigurer in order to customize the provided configuration.&lt;/p&gt;

&lt;h4&gt;
  
  
  In a nutshell
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We can have &lt;strong&gt;ONLY ONE @Configuration&lt;/strong&gt; class which annotated with the &lt;strong&gt;@EnableWebMvc&lt;/strong&gt; annotation!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we need more - we have to implement &lt;strong&gt;WebMvcConfigurer&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep in mind that this from the Spring Framework Documentation, not from Spring Boot!&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Spring MVC Auto-configuration?
&lt;/h3&gt;

&lt;p&gt;The Spring Boot Documentation says: &lt;/p&gt;

&lt;p&gt;Spring Boot provides auto-configuration for Spring MVC that works well with &lt;strong&gt;most applications&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The auto-configuration adds the following features on top of Spring’s defaults:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inclusion of ContentNegotiatingViewResolver and BeanNameViewResolver beans.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support for serving static resources, including support for WebJars.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic registration of Converter, GenericConverter, and Formatter beans.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support for HttpMessageConverters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic registration of MessageCodesResolver.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Static index.html support.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic use of a ConfigurableWebBindingInitializer bean.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to keep those Spring Boot MVC customizations and make more MVC customizations (interceptors, formatters, view controllers, and other features), you can add your own &lt;strong&gt;@Configuration&lt;/strong&gt; class of type &lt;strong&gt;WebMvcConfigurer&lt;/strong&gt; but &lt;strong&gt;without @EnableWebMvc.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to take complete control of Spring MVC, you can add your own &lt;strong&gt;@Configuration&lt;/strong&gt; annotated with &lt;strong&gt;@EnableWebMvc&lt;/strong&gt;, or alternatively add your own &lt;strong&gt;@Configuration&lt;/strong&gt;-annotated &lt;strong&gt;DelegatingWebMvcConfiguration&lt;/strong&gt; as described in the Javadoc of &lt;strong&gt;@EnableWebMvc&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  In a nutshell
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You can create your own &lt;strong&gt;@Configuration&lt;/strong&gt; which should implement &lt;strong&gt;WebMvcConfigurer&lt;/strong&gt;. But, &lt;strong&gt;do not include the @EnableWebMvc&lt;/strong&gt; annotation in this class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can use @Configuration class with the @EnableWebMvc annotation but you have to take complete control of Spring MVC and customize every aspect of its configuration and be aware that it can cause conflicts with Spring Boot's auto-configuration and make it harder to configure your application correctly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What does the Internet say?
&lt;/h3&gt;

&lt;p&gt;Baeldung mention in the section &lt;a href="https://www.baeldung.com/spring-boot-migration#migrate-a-spring-web-application"&gt;Migrate a Spring Web Application&lt;/a&gt; that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When we use &lt;code&gt;spring-boot-starter-web&lt;/code&gt; dependency, Spring Boot automatically sets up a DispatcherServlet bean and adds the &lt;strong&gt;@EnableWebMvc&lt;/strong&gt; annotation to the main Application class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we use the &lt;strong&gt;@EnableWebMvc&lt;/strong&gt; annotation in a &lt;strong&gt;@Configuration&lt;/strong&gt; class, it will &lt;strong&gt;disable&lt;/strong&gt; Spring Boot's auto-configuration for MVC.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some guy from &lt;a href="https://www.quora.com/What-is-the-use-of-EnableWebMvc-in-Spring"&gt;Quora&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Spring Boot doesn’t mix well with the standard Spring MVC @EnableWebMvc. What happens when you add the annotation is that spring boot auto-configuration is disabled.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Don’t use @EnableWebMvc in spring boot, just include spring-web as a maven/gradle dependency and it will be auto-configured.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Comments from &lt;a href="https://stackoverflow.com/questions/51008382/why-spring-boot-application-doesnt-require-enablewebmvc"&gt;Stackoverflow&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Normally you would add @EnableWebMvc for a Spring MVC app, but Spring Boot adds it automatically when it sees spring-webmvc on the classpath. This flags the application as a web application and activates key behaviors such as setting up a DispatcherServlet.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It is important to remember that 3rd point. Do not annotate any @Configuration classes with @EnableWebMvc. Otherwise, Spring MVC will load and use its own serialization/deserialization configuration, ignoring your Spring Boot config.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What you can do?
&lt;/h3&gt;

&lt;p&gt;Avoid using @EnableWebMvc in spring boot, just use &lt;code&gt;spring-boot-starter-web&lt;/code&gt; dependency and it will be auto-configured. If you need to use &lt;strong&gt;@EnableWebMvc&lt;/strong&gt; annotation in a &lt;strong&gt;@Configuration&lt;/strong&gt; be aware of the consequences.&lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/config/annotation/EnableWebMvc.html"&gt;Annotation Interface EnableWebMvc&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/Configuration.html"&gt;Annotation Interface Configuration&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.auto-configuration"&gt;Spring MVC Auto-configuration&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/spring-configuration-annotation"&gt;Spring Configuration Annotation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.quora.com/What-is-the-use-of-EnableWebMvc-in-Spring"&gt;What is the use of EnableWebMvc in Spring?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/51008382/why-spring-boot-application-doesnt-require-enablewebmvc"&gt;why spring-boot application doesn't require EnableWebMvc&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://techblog.bozho.net/spring-boot-enablewebmvc-common-use-cases/"&gt;SPRING BOOT, ENABLEWEBMVC AND COMMON USE-CASES&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.baeldung.com/spring-boot-migration#1-web-starter"&gt;Migrate a Spring Web Application&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Follow my &lt;a href="https://t.me/enterprise_developer"&gt;telegram channel&lt;/a&gt;&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>spring</category>
    </item>
    <item>
      <title>Using variables in Bazel</title>
      <dc:creator>Aleksandr</dc:creator>
      <pubDate>Thu, 16 Feb 2023 16:20:16 +0000</pubDate>
      <link>https://dev.to/xterm/using-variables-in-bazel-34o3</link>
      <guid>https://dev.to/xterm/using-variables-in-bazel-34o3</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqyvqlburuntc0idv1oi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqyvqlburuntc0idv1oi.png" alt=" " width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bazel.build/" rel="noopener noreferrer"&gt;Bazel&lt;/a&gt; is a free and open-source build and test tool developed by Google. Bazel uses a declarative language (Starlark) to describe the build and test steps. &lt;/p&gt;

&lt;p&gt;This simple guide shows how to use variables in Bazel. This can be simple done in 3 steps. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvh92ht4kgrugdxmu0tc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvh92ht4kgrugdxmu0tc.png" alt=" " width="691" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll use an fictional example of setting Java 17 as the default version of the project to show you how to use variables in Bazel.&lt;/p&gt;

&lt;h2&gt;
  
  
  1: Define the Variable in a .bzl File
&lt;/h2&gt;

&lt;p&gt;In this example we define the Variable in &lt;code&gt;rules/jdk/compatibility.bzl&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JDK17_UPWARDS = select({
    "@nasa_atlantis//rules/jdk:jdk11": ["@platforms//:incompatible"],
    "@nasa_atlantis//rules/jdk:jdk8": ["@platforms//:incompatible"],
    "//conditions:default": [],
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We use the &lt;code&gt;select&lt;/code&gt; function to choose the suitable value for the &lt;strong&gt;JDK17_UPWARDS&lt;/strong&gt; variable based on the current platform. In the example, we use Java 17 upwards if the platform supports it, or an empty list otherwise.&lt;/p&gt;

&lt;h2&gt;
  
  
  2: Import the Variable in your BUILD File
&lt;/h2&gt;

&lt;p&gt;We use the &lt;code&gt;load&lt;/code&gt; function to load specific Bazel file and import the variable from it. So, to do this we just add the line below to the BUILD file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;load("//rules/jdk:compatibility.bzl", "JDK17_UPWARDS")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It loads the &lt;code&gt;compatibility.bzl&lt;/code&gt; file and imports the &lt;strong&gt;JDK17_UPWARDS&lt;/strong&gt; variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  3: Use the Variable
&lt;/h2&gt;

&lt;p&gt;Just use the variable in your BUILD file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java_library(
    name = "nasa_atlantis-web",
    srcs = glob(["src/main/java/**/*.java"]),
    resources = glob(["src/main/resources/**/*"]),
    tags = [
        "maven_coordinates=com.nasa.spring:nasa_atlantis-web:{nasa-project}",
    ],
    target_compatible_with = JDK17_UPWARDS,
    visibility = ["//visibility:public"],
    deps = [
        "//nasa-core/nasa-events:nasa-events-sb3",
        "//libs/b-spring/nasa_atlantis-core",
        "//libs/nasa-tracing:nasa-tracing-sb3",
        "@maven_spring//:jakarta_servlet_jakarta_servlet_api",
        "@maven_spring//:org_slf4j_slf4j_api",
        "@maven_spring//:org_springframework_boot_spring_boot",
        "@maven_spring//:org_springframework_boot_spring_boot_autoconfigure",
        "@maven_spring//:org_springframework_boot_spring_boot_starter",
        "@maven_spring//:org_springframework_boot_spring_boot_starter_web",
        "@maven_spring//:org_springframework_spring_beans",
        "@maven_spring//:org_springframework_spring_context",
        "@maven_spring//:org_springframework_spring_core",
    ],
)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our example, we use the &lt;strong&gt;JDK17_UPWARDS variable&lt;/strong&gt; in the &lt;strong&gt;java_library&lt;/strong&gt; rule as the attribute named  &lt;strong&gt;target_compatible_with&lt;/strong&gt;. This attribute specifies the versions of the Java language that the target is compatible with.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuws6ppurzp3snbtcg8as.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuws6ppurzp3snbtcg8as.png" alt=" " width="267" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ERROR: name is not defined
&lt;/h2&gt;

&lt;p&gt;You could have the issue below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR: /builds/platform/nasa/libs/nasa_atlantis-web/BUILD:22:30: name 'JDK17_UPWARDS' is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reason is likely because you forgot to import the variable in your BUILD file or the path is wrong. For example you use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;load("///rules/jdk:compatibility.bzl", "JDK17_UPWARDS")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;load("//rules/jdk:compatibility.bzl", "JDK17_UPWARDS")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats it.&lt;/p&gt;

&lt;p&gt;Follow me in the group in &lt;a href="https://t.me/enterprise_developer" rel="noopener noreferrer"&gt;telegram&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://enterprise-developer.com" rel="noopener noreferrer"&gt;My blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>career</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>SAP Hybris code review checklist</title>
      <dc:creator>Aleksandr</dc:creator>
      <pubDate>Sat, 10 Jul 2021 13:30:21 +0000</pubDate>
      <link>https://dev.to/xterm/sap-hybris-code-review-checklist-573h</link>
      <guid>https://dev.to/xterm/sap-hybris-code-review-checklist-573h</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D_ns52PO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdm9wfvh0w642d1isk3s.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D_ns52PO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdm9wfvh0w642d1isk3s.jpg" alt="Alt Text" width="800" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  General
&lt;/h2&gt;

&lt;p&gt;Because the code should be fully extensible and easy to test, the reviewed code should not contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;final methods/classes (except low-level platform features)&lt;/li&gt;
&lt;li&gt;private methods&lt;/li&gt;
&lt;li&gt;static methods&lt;/li&gt;
&lt;li&gt;Utility classes should have only static methods and with &lt;strong&gt;very simple functionality&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  *-items.xml
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;All Item Types which are extending GenericItem should have a deployment table.&lt;/li&gt;
&lt;li&gt;All many-to-many relations should have a deployment table.&lt;/li&gt;
&lt;li&gt;Deployment type codes must be greater than 10000.&lt;/li&gt;
&lt;li&gt;Check that more abstract types are defined more to the beginning of the items.xml and more concrete types are more to the end. &lt;/li&gt;
&lt;li&gt;Item type names must be started with an uppercase letter.&lt;/li&gt;
&lt;li&gt;Item type names should not be started with Generated&lt;/li&gt;
&lt;li&gt;Attribute names should be started with a lowercase letter.&lt;/li&gt;
&lt;li&gt;Item type must have at least one unique attribute.&lt;/li&gt;
&lt;li&gt;The Item type assignment must be described in the description tag.&lt;/li&gt;
&lt;li&gt;Mandatory attributes (optional="false") should have either initial value defined.&lt;/li&gt;
&lt;li&gt;Boolean attributes must be defined (because they could store null/true/false).&lt;/li&gt;
&lt;li&gt;Relations that have cardinality='many' should not have option ordered='true' unless absolutely necessary.&lt;/li&gt;
&lt;li&gt;CatalogVersion attributes must be unique for Catalog aware types.&lt;/li&gt;
&lt;li&gt;Unique attributes should have database indexes.&lt;/li&gt;
&lt;li&gt;Check whether the attribute needs to be localized.&lt;/li&gt;
&lt;li&gt;Check those attribute definitions are not changed.&lt;/li&gt;
&lt;li&gt;Check that deployment code or table names are not changed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ImpEx
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;There is no mixing headers&lt;/li&gt;
&lt;li&gt;There is INSERT_UPDATE rather than INSERT in Large, One-hit Imports&lt;/li&gt;
&lt;li&gt;Many-to-many Relations are imported separately&lt;/li&gt;
&lt;li&gt;Essential data impexes should only contain must needed data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Service and DAO
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Name of the interfaces of services should be the related domain concept with Service on the end.&lt;/li&gt;
&lt;li&gt;The interfaces of services should be located in the root package or in a subpackage named after the domain concept if appropriate (example: &lt;em&gt;de.hybris.platform.catalog.CatalogService&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;Services should not contain Flexible search queries inside business logic&lt;/li&gt;
&lt;li&gt;The names of interfaces for DAO should be ended with DAO&lt;/li&gt;
&lt;li&gt;DAO interfaces should be located in a package &lt;strong&gt;daos&lt;/strong&gt; underneath the package of the service interface. (example: &lt;em&gt;de.hybris.platform.catalog.&lt;/em&gt;&lt;em&gt;daos&lt;/em&gt;&lt;em&gt;.CatalogDao&lt;/em&gt;, &lt;em&gt;de.hybris.platform.catalog.&lt;/em&gt;&lt;em&gt;daos&lt;/em&gt;&lt;em&gt;.impl.DefaultCatalogDao&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;DAO methods should be named as findByXXXX where XXXX lists the parameters for the method&lt;/li&gt;
&lt;li&gt;DAO/Service should not return null&lt;/li&gt;
&lt;li&gt;DAO should return an empty list if nothing is found&lt;/li&gt;
&lt;li&gt;DAO should use FlexibleSearchService.searchUnique() when searching for a single item&lt;/li&gt;
&lt;li&gt;DAO should use pagination for potentially large queries to prevent performance issues&lt;/li&gt;
&lt;li&gt;Services method should be named with the following pattern: getFor(). For example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;ProductModel&lt;/span&gt; &lt;span class="nf"&gt;getProductForCode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ProductModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getProductsForCategory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CategoryModel&lt;/span&gt; &lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ProductModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getOnlineProductsForBrand&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BrandModel&lt;/span&gt; &lt;span class="n"&gt;brand&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If more than one is found for a single result, it should throw &lt;strong&gt;AmbiguousIdentifierException&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;If none is found, it should throws &lt;strong&gt;UnknownIdentifierException&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;It is useful to use a parameter object instead of a long list of method parameters.&lt;/li&gt;
&lt;li&gt;Instead of IllegalArgumentException use &lt;strong&gt;ServicesUtil.validateParameterNotNull&lt;/strong&gt;,or analogs to check if an input parameter was provided.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Each class should have a related test class (including web classes) in the same package as the class it is testing but under the testsrc folder.&lt;/li&gt;
&lt;li&gt;All public methods should be covered by unit tests.&lt;/li&gt;
&lt;li&gt;Happy path scenario should be covered&lt;/li&gt;
&lt;li&gt;All exception scenarios should be covered&lt;/li&gt;
&lt;li&gt;Basic edge cases should be covered&lt;/li&gt;
&lt;li&gt;Tests should not depend on other tests&lt;/li&gt;
&lt;li&gt;Tests should roll back their transaction or clean up after themselves completely&lt;/li&gt;
&lt;li&gt;Tests should be responsible for inserting the data they require&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Misc
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Existed properties should not be changed&lt;/li&gt;
&lt;li&gt;Properties should be documented&lt;/li&gt;
&lt;li&gt;Listener classes should not contain any significant business logic inside.&lt;/li&gt;
&lt;li&gt;DTO beans should be defined in beans.xml files instead of java classes.&lt;/li&gt;
&lt;li&gt;Controllers should use Facades, not Services and Daos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Created based on official documentation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="http://enterprise-developer.com/"&gt;my tech blog&lt;/a&gt; and &lt;a href="https://t.me/enterprise_developer"&gt;telegram&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hybris</category>
      <category>codereview</category>
      <category>java</category>
    </item>
    <item>
      <title>MACHathon - what it was for me?</title>
      <dc:creator>Aleksandr</dc:creator>
      <pubDate>Tue, 11 May 2021 07:24:52 +0000</pubDate>
      <link>https://dev.to/xterm/machathon-what-it-was-for-me-1001</link>
      <guid>https://dev.to/xterm/machathon-what-it-was-for-me-1001</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kDJ7Awjy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fy9aospbix9kb5o8st5e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kDJ7Awjy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fy9aospbix9kb5o8st5e.jpg" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
I was looking at the console and I didn’t understand what’s wrong. That was my first time when I use Vue Storefront, I was recognized that I’ve lost the thread. I don’t understand how to fix it and how it works. Sad thoughts, but it was a chance to learn something new. Yup, I was finding something positive at this moment. I have limited time and it should work properly otherwise we will fail.&lt;/p&gt;

&lt;p&gt;A month before, on a frosty December evening, I got an email from my resource manager. He asked me to volunteer in hackathon with some strange name - MACHathon. I did little research. The organizer of MACHathon is The MACH Alliance. The Alliance was formed in June 2020 as a non-profit co-operation to introduce a new, open, and best-of-breed enterprise technology ecosystem. Founded by commercetools, Contentstack, and EPAM Systems.&lt;/p&gt;

&lt;p&gt;I’ve heard about commercetools and it was an opportunity for me to try new things, but I’m waiting for a new project on my work and I was doubtful that I can successfully engage hackathon. I answered that I think about it. The theme of the hackathon was - Getting Unstuck. That means MACHathon should show up new ideas on how to help people get virtually un-stuck. I spent my New Year holidays finding the idea, but I didn’t find anything valuable. All my ideas looked banal or useless, so I stopped my research.&lt;/p&gt;

&lt;p&gt;A few weeks later I suddenly was invited to the internal meeting there I found out that I was participating in MACHathon and during this meeting, a few teams were built and I was added to one of them. I became the fourth on the team. In addition to me in the team were another two backend developers - Andrey and Artem, and the head of the team was Olesia - experienced team lead. Our team contained only backend developers and we start to realize that we can potential problems building some beautiful fronted for our solution.&lt;/p&gt;

&lt;p&gt;We were a bit confused. We didn’t know what we had to develop, we had to find out the idea quickly and send a request to participate MACHathon. It should be something simple to implement, usefull, and related to the theme. After a quick brainstorm session, we decided to develop a telegram bot that should help out senior people with buying groceries. It didn’t sound like rocket science, was simple and to be honest a little bit boring. First, we didn’t decide what frontend we have to use, then after some research, I found out that vue stroefront is a possible choice for this solution and others were accepted that.&lt;/p&gt;

&lt;p&gt;We were starting our work. I was starting by bootstrapping and investigating a simple internet shop built by vue storefront and try to integrate it into commercetools. Andrey simply builds the backend part for several evenings. Luckily he was into developing telegram bots and it didn’t something extremely new for him. When we had problems connect the parts of our work. In the middle of this Artem was left us for few days - he had some urgent personal matters and couldn’t engage hackathon.&lt;/p&gt;

&lt;p&gt;It was a week of a mess, stress, and doubts. We had no hope to build something expressive, no, we refused any improvements, just want to implement the core idea of the application. At the end of the week, we had an app deployed on Heroku. We could buy groceries using our app (without placing real orders of course). Our team leader finished some paperwork, I edited the video for the presentation and we forget about MACHathon for a while. After few days we recognized that we won the category The Relevance Award.&lt;/p&gt;

&lt;p&gt;What I’ve learned and what I’ve got.&lt;/p&gt;

&lt;p&gt;-I got a jolt&lt;br&gt;
-I’ve tried to use cut edge technologies and I want to use them again&lt;br&gt;
-MACHathon has given me confidence in my business&lt;br&gt;
-I have been confirmed in the opinion that for hackathons, some raw solution is better than a non-working but with fantastic perspectives one.&lt;br&gt;
-I got branded stuff from The MACH Alliance))&lt;/p&gt;

&lt;p&gt;Our project on devpost:&lt;br&gt;
&lt;a href="https://devpost.com/software/shopping-helper-bot"&gt;https://devpost.com/software/shopping-helper-bot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MACHaton winners:&lt;br&gt;
&lt;a href="https://machalliance.org/insights/machathon-2021-winners-solutions-for-getting-unstuck-"&gt;https://machalliance.org/insights/machathon-2021-winners-solutions-for-getting-unstuck-&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow me in the group in &lt;a href="https://t.me/enterprise_developer"&gt;telegram&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Original post &lt;a href="http://enterprise-developer.com/2021/04/16/MACHaton-what-it-was-for-me/"&gt;http://enterprise-developer.com/2021/04/16/MACHaton-what-it-was-for-me/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machathon</category>
      <category>commercetools</category>
      <category>machalliance</category>
      <category>vuestorefront</category>
    </item>
    <item>
      <title>SAP Commerce (Hybris) interview questions with answers - Part 1 - Data Model.</title>
      <dc:creator>Aleksandr</dc:creator>
      <pubDate>Thu, 24 Dec 2020 07:52:41 +0000</pubDate>
      <link>https://dev.to/xterm/sap-commerce-hybris-interview-questions-with-answers-part-1-data-model-4i3a</link>
      <guid>https://dev.to/xterm/sap-commerce-hybris-interview-questions-with-answers-part-1-data-model-4i3a</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F42c79uuqwfnhartajysc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F42c79uuqwfnhartajysc.jpg" alt="image from wikimedia.org"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  When do you need to use a deployment table?
&lt;/h3&gt;

&lt;p&gt;All items that don't have a deployment table are stored in the &lt;strong&gt;genericitems&lt;/strong&gt; table. It makes the genericitems table extremely large. This makes the database work inefficiently causing performance issues.&lt;br&gt;
Need to define a deployment table for all item types that extend GenericItem except abstract item type. &lt;/p&gt;

&lt;h3&gt;
  
  
  When you can’t use a deployment table?
&lt;/h3&gt;

&lt;p&gt;When Item Types already has a deployment inherited from a supertype. Technically it's possible but is not recommended because you will get performance issues because the supertype requires a UNION clause with a new table.&lt;/p&gt;

&lt;h3&gt;
  
  
  What deployment type codes can you use?
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;itemtype&lt;/span&gt; &lt;span class="na"&gt;code=&lt;/span&gt;&lt;span class="s"&gt;"UrlPolicy"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;deployment&lt;/span&gt; &lt;span class="na"&gt;table=&lt;/span&gt;&lt;span class="s"&gt;"UrlPolicy"&lt;/span&gt; &lt;span class="na"&gt;typecode=&lt;/span&gt;&lt;span class="s"&gt;"18703"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;attributes&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;attribute&lt;/span&gt; &lt;span class="na"&gt;qualifier=&lt;/span&gt;&lt;span class="s"&gt;"symbolsToReplaceRegex"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"java.lang.String"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;persistence&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"property"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;modifiers&lt;/span&gt; &lt;span class="na"&gt;read=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt; &lt;span class="na"&gt;write=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;description&amp;gt;&lt;/span&gt;Some attribute&lt;span class="nt"&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/attribute&amp;gt;&lt;/span&gt;
        ....
    &lt;span class="nt"&gt;&amp;lt;/attributes&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/itemtype&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you don't want to have problems in the future use type codes larger than &lt;strong&gt;10000&lt;/strong&gt;. Because the Hybris platform uses type codes from 0 to 10000.&lt;/p&gt;

&lt;h3&gt;
  
  
  What types of relations are required a deployment table?
&lt;/h3&gt;

&lt;p&gt;If a many-to-many relation does not have a deployment table, it's data stores in the links table along with the data from all the other many-to-many relations that don't have a deployment table. Of course, you will get serious performance problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  How many values can a boolean attribute store? Should you define it?
&lt;/h3&gt;

&lt;p&gt;A Boolean attribute can store 3 values - true, false, null. So, you need to define a default value for the Boolean attribute if you want to avoid problems with NullPointerExceptions.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="c1"&gt;// Potential NPE&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isSpecial&lt;/span&gt;&lt;span class="o"&gt;()){&lt;/span&gt;&lt;br&gt;
    &lt;span class="n"&gt;someService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;doSomething&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;&lt;br&gt;
&lt;span class="o"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  What are the requirements for item types names and attributes?&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Item type Names&lt;/strong&gt; should start with an uppercase letter&lt;br&gt;
&lt;strong&gt;Item type attributes&lt;/strong&gt; should start with a lowercase letter.&lt;br&gt;
&lt;strong&gt;qualifier names&lt;/strong&gt; should start with a lowercase letter.&lt;br&gt;
Don't start Item type names with &lt;strong&gt;Generated&lt;/strong&gt;, for example, &lt;em&gt;GeneratedUserQuery&lt;/em&gt; - it reserved for Hybris abstract classes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should we use a relation that has cardinality='many' with attribute ordered=true, or it is a bad practice?
&lt;/h3&gt;

&lt;p&gt;An option ordered='true' on any side of a relation that has cardinality='many' has a significant impact on performance when reading and writing from the database. Hybris build very complex queries to provide a defined order to the items that are much more complex and expensive than an unordered query.&lt;/p&gt;

&lt;h3&gt;
  
  
  What type of collection recommended to use for a relation that has cardinality='many'?
&lt;/h3&gt;

&lt;p&gt;You have to use collectiontype='set' on any side of a relation that has cardinality='many' where items must not appear in that relation multiple times.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should CatalogVersion attributes be unique for Catalog aware types?
&lt;/h3&gt;

&lt;p&gt;Yes. Because the CatalogVersion attribute forms part of the unique key for Catalog Synchronization. Otherwise, you'll spend Friday night debugging.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do we need to define database indexes for the unique attributes of type? Will this help us avoid duplicates?
&lt;/h3&gt;

&lt;p&gt;The only database can guarantee no duplicates. The validation of the unique attributes in the Service Layer cannot entirely guarantee that there won't be duplicate records in the database.&lt;br&gt;
So, you have to define database indexes for the unique attributes of the type.&lt;/p&gt;

&lt;h3&gt;
  
  
  What’s wrong with having a catalog aware type on the “many side” of a one-to-many relation?
&lt;/h3&gt;

&lt;p&gt;You'll get an issue when synchronizing. The reference to the Catalog aware type will be transferred from the Staged to the Online version. The Staged version will no longer have a reference.&lt;/p&gt;

&lt;h3&gt;
  
  
  When do we need to have unique attributes for all types?
&lt;/h3&gt;

&lt;p&gt;Always. All types should have unique attributes. This allows avoid duplicates and ensure import/export by IMPEX.&lt;/p&gt;

&lt;h3&gt;
  
  
  When do we need to use unoptimized attributes?
&lt;/h3&gt;

&lt;p&gt;Never. Option dontOptimize="true" allows storing the data for this type in a secondary table defined by the &lt;strong&gt;propertytable&lt;/strong&gt; attribute of the deployment or the props table if no propertytable is defined. hybris builds complex and expensive queries to handle it.&lt;/p&gt;

&lt;h3&gt;
  
  
  When do we have to create a new sub-type and when have we not?
&lt;/h3&gt;

&lt;p&gt;We should extend the existing type when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Need to add a new attribute for all instances
We should create a new sub-type when:&lt;/li&gt;
&lt;li&gt; Need to add a new attribute for specific instances&lt;/li&gt;
&lt;li&gt; Need to redeclare an existing attribute (for example change mandatory to optional)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What should we do with unnecessary indexes?
&lt;/h3&gt;

&lt;p&gt;We should remove unnecessary indexes. Indexes should only exist for attributes used in flexible searches. Hybris creates a significant number of database indexes that many projects never use and those indexes slow down the writing to the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  How often do we need to use collections in items.xml?
&lt;/h3&gt;

&lt;p&gt;Collection types can cause truncation issues, so we have to use relations instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can we change attribute definitions?
&lt;/h3&gt;

&lt;p&gt;Sure, but the modification of an attribute qualifier has serious consequences on a system update. &lt;br&gt;
&lt;strong&gt;A change of upper/lower spelling&lt;/strong&gt; will change the signature of generated getters/setters, so it will cause API incompatibilities. &lt;br&gt;
&lt;strong&gt;A change of spelling&lt;/strong&gt; is the same as removing the attribute from items.xml and defining a new one with a different name. The old data is not accessible anymore by generated API.&lt;br&gt;
&lt;strong&gt;A change of type&lt;/strong&gt;. If the database does not support changing the type, changing the attribute type will not change the database schema. Nevertheless, the generated API will be changed, resulting in incompatibilities and a high probability of exceptions at runtime. &lt;br&gt;
&lt;strong&gt;The modification of attribute type in redeclaration mode&lt;/strong&gt; can throw a build error in case of incompatible type hierarchy (for example type of attribute was from String to Long).&lt;br&gt;
&lt;strong&gt;Modification of columntype (subtag of persistence type)&lt;/strong&gt; will succeed if the type is compatible on the database level, otherwise, no effect happens.&lt;br&gt;
&lt;strong&gt;With the modification of attribute modifiers&lt;/strong&gt;, you could get API incompatibilities due to the read and write flag influences code generation. &lt;br&gt;
&lt;strong&gt;All other modifier modifications&lt;/strong&gt; will cause different behavior which can be serious too and must be checked in detail. (for example: adding a unique flag can cause inconsistent data).&lt;/p&gt;

&lt;h3&gt;
  
  
  Can we change deployment code or table names?
&lt;/h3&gt;

&lt;p&gt;Changing deployment code has fatal consequences. If you change the table name, you get a new table, and you lose access to the old data. It's because the typecode specified in a deployment tag forms part of the PK of the items inside the database. It helps find items very quickly by their PK because the typecode points directly to the correct database table. If you change a typecode for a table then all old items inside the table will not be found anymore and are lost with it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can we change a type declaration?
&lt;/h3&gt;

&lt;p&gt;You should not change a type declaration because modifying the values of an existing itemtype tag will result in API incompatibilities between the two versions. This breaks backward compatibility and makes upgrades harder.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can we improve the performance of large impex import?
&lt;/h3&gt;

&lt;p&gt;You can define a database index on the lookup value of reference types for using it in IMPEX-import for example.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="http://enterprise-developer.com/" rel="noopener noreferrer"&gt;my tech blog&lt;/a&gt; and &lt;a href="https://t.me/enterprise_developer" rel="noopener noreferrer"&gt;telegram&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hybris</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
