GORM executeQuery nuance

 

by Taras Matyashovsky

 

 

As far as You know executeQuery method allows the execution of HQL queries against a domain class. In previous post I mentioned issue concerning it in Grails. To recall I will list the latest query using Groovy shortcuts once more:

 

DocumentRevision.executeQuery("select

max(dr.versionNumber) from

${DocumentRevision.name} dr")

 

Now I want to mention one nuance more. In my query I suppose that result type would be a numeric cause versionNumber property is Long type. But result type of using executeQuery method is always java.util.ArrayList. So even if You try to retrieve maximal value of some field, or count of some records the result type will always be ArrayList. Pay attention to that fact.

 

If You are not satisfied with such behavior of executeQuery method please refer to createCriteria method.

 

 

Comments  

 
0 # Quake 2009-12-01 03:41 test Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-01 04:26 test2 Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-01 04:34 hi Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-01 04:40 good Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-01 04:43 fgh Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-01 04:44 wer Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-02 06:40 hhk Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-02 06:55 gjg Reply | Reply with quote | Quote
 
 
0 # Quake 2009-12-02 08:11 qw Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh