[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-277) allow string values for query hints

Nikolai Gagov (JIRA) noreply at atlassian.com
Tue Jan 13 09:21:39 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32108#action_32108 ] 

Nikolai Gagov commented on EJB-277:
-----------------------------------

Here is also my solution, seems that for some hints Hibernate expects Boolean instead of String, and due to the reason that Seam's entity query acepts hints only as String query.setHints(Map<String, String>), we need to override that..

> allow string values for query hints
> -----------------------------------
>
>                 Key: EJB-277
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-277
>             Project: Hibernate Entity Manager
>          Issue Type: Improvement
>          Components: EntityManager
>            Reporter: Norman  Richards
>             Fix For: 3.3.2.Beta2
>
>         Attachments: CustomEntityQuery.java
>
>
> It seems that some string values are not accepted as query hint values in hibernate.  In specific, I was trying to convert a simple query that uses setHint("org.hibernate.cacheable", true) to use an XML-defined EntityQuery that uses 
>     <framework:entity-query name="allCategories"
>                             ejbql="select c from Category c"
>                             order="c.name">
>        <framework:hints>
>             <key>org.hibernate.cacheable</key>
>             <value>true</value>
>         </framework:hints>
>     </framework:entity-query>    
>    Unfortunately, this fails with an IllegalArgumentException:
> 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:114)
>         at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:41)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         ...
> Although I didn't try it, I would assume this would also fail from a @QueryHint in on a named query since that annotation only accepts a string 
> value.
> I don't think this is technically a bug, but it would be very convenient if all the hints could accept string values.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list