title: Combining @NonBlocking with HIbernate ORM during application startup
body: <p>In my application I need to initialize content from a database at startup.</p>
  <p>The following article: <a href="https://quarkus.io/blog/resteasy-reactive-smart-dispatch/" rel="nofollow noreferrer">https://quarkus.io/blog/resteasy-reactive-smart-dispatch/</a> mentions the following.</p>
  <p>&quot;As Hibernate ORM classic (we also have Hibernate reactive) is blocking, you can’t use it with RESTEasy reactive without using the @Blocking annotation. This annotation changes the dispatching strategy to use a worker thread (instead of the I/O thread).&quot;</p>
  <p>It goes on that stuff has been simplified by looking at the signature of the method called. If you  signature implies synchronous behavior, the &quot;worker thread&quot; is chosen. If not, the (faster) reactive mechanism is preferred (i/o thread).</p>
  <p>It also mentions Hibernate reactive as opposed to Hibernate classic. I've not explored into that realm yet.</p>
  <hr />
  <p>But, starting from here I want to try to do the following:</p>
  <pre class="lang-java prettyprint-override"><code>@Startup 
  @ApplicationScoped
  public class I18NBean{
  
     public static Map&lt;String, String&gt; I18N = init();
  
  
     private static Map&lt;String,String&gt; init(){
  
          // initialize map from DB
     }
  
     public String translate(String in){
         return I18N.get(in);
     }
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>
  @Path(&quot;/hello&quot;)
  public class GreetingResource {
  
    @Inject
    I18NBean translations;
  
     @POST
     @NonBlocking
     public String hello( String in ) {
         return translations.translate( in );
     }
  }
  </code></pre>
  <p>making use of the I/O thread for the resource and doing the hibernate (classic) interaction at startup.</p>
  <p>The simple question: would that work? I am going to try this myself coming days, but perhaps there are some fundamental things that I overlook or perhaps there's a better strategy / designs such as using a lifecycle method.</p>
  <pre class="lang-java prettyprint-override"><code>    void onStart(@Observes StartupEvent ev) {               
          LOGGER.info(&quot;The application is starting...&quot;);
      } 
  </code></pre>