I like the first one most, because:
-
no new syntax to learn
-
people can copy/paste queries from their other tools, nice for testing them, excellent to paste from blogs/books.
-
if a database doesn't support parameters natively (and in their native Java driver) maybe it's not useful or doesn't make sense at all in the specific domain of the tool
-
if in a database engine it would make sense but they couldn't care less to provide this functionality to java clients, I'm not going to do their homework. At best we could contribute the feature if it's somehow badly needed.
Also note the syntax proposed in the other examples isn't valid escaping, you'd need also an end-delimiter as we discussed to avoid potential ambiguities. So the second example would need to be at the very least
@NamedNativeQuery(name = "MyQuery", query = "@MATCH (n) WHERE n.name = ${name}$ RETURN n", resultClass = Foo.class )
An alternative to escaping could be to find an ad-hoc solution for each language, to exploit some illegal token.. and use escaping only as a last resort.
|