[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2676) Cannot apply UPGRADE lock to scalar Query object

Pierre-Vincent Arnaud (JIRA) noreply at atlassian.com
Mon Oct 1 11:22:25 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28267 ] 

Pierre-Vincent Arnaud commented on HHH-2676:
--------------------------------------------

Have a look at the following issue : http://forum.hibernate.org/viewtopic.php?t=943045&highlight=alias+lockmode.

Gavin's advice is sensible, isn't it?

> Cannot apply UPGRADE lock to scalar Query object
> ------------------------------------------------
>
>                 Key: HHH-2676
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2676
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.1
>            Reporter: John Wood
>            Priority: Minor
>         Attachments: Bean.hbm.xml, Bean.java
>
>
> If you try and add a lock to a Query object (against a named alias) when doing a scalar HQL query (e.g. "select sum(foo) from bah") then an error occurs.
> The sample code (full working example is attached):
>    // Create query
>    Query q = session.createQuery("select b.value from Bean b");
> 		
>    // Set lock mode on query 
>    q.setLockMode("b", LockMode.UPGRADE);
>    // Executre
>    q.list();
> This causes the following error:
>      Exception in thread "main" java.lang.IllegalArgumentException: could not locate alias to apply lock mode : b
> 	at org.hibernate.loader.hql.QueryLoader.applyLocks(QueryLoader.java:297)
> 	at org.hibernate.loader.Loader.preprocessSQL(Loader.java:201)
> 	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538)
> 	at org.hibernate.loader.Loader.doQuery(Loader.java:673)
> 	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
> 	at org.hibernate.loader.Loader.doList(Loader.java:2220)
> 	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
> 	at org.hibernate.loader.Loader.list(Loader.java:2099)
> 	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
> 	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
> 	at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
> 	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
> 	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> I have tried this both with an older version of Hibernate (3.1) and the latest with the same result (although the older Hibernate has the error message "alias not found".
> I have attached a simple example to demonstrate this.
> See also HHH-1965.
> Perhaps, it is simply that one cannot lock scalar queries of this type. If so, then the fix would presumably be to include this in the Query class Javadocs.

-- 
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