2 Replies Latest reply on Jun 19, 2008 4:37 PM by btonez

    Custom EntityManager or Unwanted Entites not loaded

    jbossindia

      I am working on SaaS app. I have tenentid in all of the tables and want to make sure that irrespective of the developer the HQL should be parsed and it should be looked if tenentid is given in parameter otherwise an exception is thrown.


      I am thinking of two ways:


      1. Implment the Custom Entitymanager
      2. or the Hibernate Entity should not get loaded somehow


      I don't know how to do either of the ways


      Please suggest.

        • 1. Re: Custom EntityManager or Unwanted Entites not loaded
          stephen

          You question is a little hard to parse ;-)


          Anyway: Maybe a Hibernate filter is what you need?


          See the hibernate docs:


          Filtering data


          How Seam makes using filters easier:


          Using Hibernate filters

          • 2. Re: Custom EntityManager or Unwanted Entites not loaded
            btonez

            I think that what he's asking is to programatically ensure that the developers in his project all specify a tenentid in their HQL query strings.  If you really need to do this at runtime (it would be a performance hit), take a look at the classes in src/main/org/jboss/seam/persistence.  You might be able to override one of them, then explicitly install it in components.xml. 


            Even better, see if there's some way to add a restriction to your build that searches java files for strings beginning with select or from, then checks that they include tenentid before allowing the files to be compiled.  This would find bugs at compile time, not runtime.