I have spent a lot of time on this problem. Anyone has any insights?
I think you have to remove MY_TABLE befor the column names, because you are working only into this table, called MY_TABLE and you aren't using other tables (Joins).
Maybe you can also remove the id = ... . Try it.
did you try running the generated query in an sql tool? I dont think your subquery makes any sense, and I think the table names are 100% ambiguous.
Group by normally needs to be a non-aggregated field present in the result set. max(x) ... group by x doesn't make any sense.
MY_TABLE.id = (select max(a.id) from MY_TABLE a)