1 Reply Latest reply on Oct 28, 2006 5:46 AM by mnrz

    @factory and Contexts

    mrohad

      I am using the Factory annotation many times and it might cause a problem when a user choose a different language because then all my queries are different and has to rerun...

      I wonder if there is a way to clean the factory cache , what about Contexts.destroy(converstionCopntext)?

        • 1. Re: @factory and Contexts
          mnrz

          Hi

          In my opinion you should create a factory class in which you choose proper instance to select from database depend on given locale.

          for example, if you support two locales you should have something like this:

          interface Country {}

          class CountryEnglish implement Country{}

          class CountryFrench implements Country{}

          then your factory class:
          class CountryFactory {
          static Country getInctance(int localeId){
          if(localeId == ENGLISH){
          return new CountryEnglish();
          }
          if(localeId == FRENCH){
          return new CountryFrench();
          }
          }
          }

          and you should put EntityManager in those two class and call them to select from database instead of calling "em" directly.

          hope this help.