google-code-export / simplejpa

Automatically exported from code.google.com/p/simplejpa
1 stars 0 forks source link

Domain class names containing "count" break GORM list() / find #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create Grails project with GORM-JPA installed & Hibernate uninstalled and 
setup SimpleJPA as EM and domain class named "Account"
2. Call Account.list()

What is the expected output? What do you see instead?
Should eval to a List<String> of Account ids
Instead, get a List<Long> with one element containing the number of items/rows

What version of the product are you using? On what operating system?
SimpleJPA 1.5

Please provide any additional information below.

The query issued in response to list() is: select count(*) from...
whereas is the domain class is renamed so that "count" is not a substring
then the query is: select * from...

I believe this is due to code in simplejpa/query/QueryImpl.java that reads:
    if (select != null && select.contains("count")) {
      count = true;
 and similar, presumably because the Grails GORM list() uses find.

Took me two intensive days to finally figure that out! - hope it helps someone.

Original issue reported on code.google.com by David.Li...@gmail.com on 10 Oct 2010 at 5:58