3 Replies Latest reply on Oct 31, 2010 9:40 PM by joykhalifa

    EntityQuery setHints()

    gaborj

      Hi Guys,


      Using Seam 2.1.2 I'm trying to use the setHints(Map<String,String>) in EntityQuery


      if(cachable){
           Map<String,String> queryHints = new HashMap<String,String>();
           queryHints.put("org.hibernate.cacheable", cachable.toString());
           setHints(queryHints);
      }



      but then I get:


      Caused by: java.lang.IllegalArgumentException: Value for hint
           at org.hibernate.ejb.QueryImpl.setHint(QueryImpl.java:160)
           at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:190)



      Probably I'm overlooking s.g. please give me some hint ;)...
      also thinking what is the reason for the Map<String,String> on this API...?


      thanks,
      Gabor

        • 1. Re: EntityQuery setHints()
          mikkus70

          In hibernate, you can pass the hints either as Object, as in:


          setHint("org.hibernate.cacheable",new Boolean(true))
          



          or as a string equivalent, as in:


          setHint("org.hibernate.cacheable", "true")
          



          That's the reason why you see a Map<String,String>, it expects the String equivalent of the hint value. So, you need to pass a string containing the value of the boolean property you want to pass. In your example, if cachable is a Boolean object, a toString() should return true or false and the query should work.


          The exception you see is issued when the hint value cannot be casted into a string. I would try putting "true" instead of cachable.toString(), you already test cachable there so it is safe to do so...

          • 2. Re: EntityQuery setHints()
            gaborj

            Yes, the


            setHint("org.hibernate.cacheable", "true")



            was my first try, but resulted the same...

            • 3. Re: EntityQuery setHints()
              joykhalifa

              Hello dear,
              My name is Miss Joy Khalifa, As I search for a nice friend and came across your contact, My mind and my heart told me to contact you for friendship, A friend who truly understand his or her friend and share their feelings together. please kindly accept my request, I believe that distance or age can never be a barrier but let love connect us because love is a bridge that connected far distance to be close to each other, I will send my pictures to you immediately I receive your reply at my email address ( joyfullkhalifa@yahoo.com ).
              Your Friend,
              Joy.