I have a rather mundane Oracle table with seven rows. Each row has different values, there is a unique key that keeps most of the columns from having similar data.
In a Grails controller I am running the following code:
else if (request.method == "GET" && params.term) {
def a = WaiverExemption.findAll("from WaiverExemption as e where e.exemptionTermCode.id = ?", [parseLong(params.term)]) as JSON
a.render(response)
return false
}
The browser is making the correct request to this. It passes in a valid term, and in the IntelliJ debugger I can see that the term is correct. Until sometime last week, this particular snippet of code was working correctly… my troubles were related to getting Backbone and jQuery to make use of the json data returned.
Now, instead of returning the 7 rows of data that I expect, it returns the same row 7 times. This row happens to be the first row returned in the Oracle client (though since I wasn’t using any order by, technically speaking, it’s not the first row at all… no guarantee of order and all that).
So far I’ve done multiple “grails clean” on it. I have of course stopped and restarted the application multiple times, and I’ve tried this both in debug and regular execution.
The only change to this code was the addition of another column in the domain class. But the timing doesn’t correspond well to when this started screwing up. The new column was actually Oracle’s ROWID, which I didn’t expect to work but did make another problem easier to solve. Removing that doesn’t revert this to working, however.
Can anyone explain this behavior?
[edit] Debug results after fixing the config.groovy as requested:
2012-09-17 10:26:02,675 [http-bio-8080-exec-7] DEBUG hibernate.SQL - select waiverexem0_.EXEMPTION_TERM_CODE as EXEMPTION1_26_, waiverexem0_.exemption_activity_date as exemption2_26_, waiverexem0_.exemption_classification as exemption3_26_, waiverexem0_.exemption_code as exemption4_26_, waiverexem0_.exemption_pay_type as exemption5_26_, waiverexem0_.exemption_priority as exemption6_26_, waiverexem0_.ROWID as ROWID7_26_, waiverexem0_.exemption_term_code as exemption1_26_, waiverexem0_.exemption_user_id as exemption8_26_ from TT_ST_GRADUATE_EXEMPTION waiverexem0_ where waiverexem0_.exemption_term_code=?
I haven’t seen this specific problem before, but were I to encounter it I would debug it like so:
println params.term