rewritten query syntax exception to java