3 ms·
I wonder if annotations and annotation pre-processors could have been an alternate way to approach this had they been applicable to String constants. Strin
by tofflos 4y ago
I wonder if annotations and annotation pre-processors could have been an alternate way to approach this had they been applicable to String constants.
String name = "Joan";
PreparedStatement query = @SQL "select * from users where firstname = \{name}";
- ivan_gammel 4y agoAnnotations are declarative, processors are imperative. You need an interface with a method to run the processing.
- thamer 4y agoThis also made me think of prepared statements. It would be more readable to have all the values in their respective place in the SQL string, rather than have a bunch of question marks followed by all the values bunched together at the end. e.g. this: PreparedStatement query = SQL."SELECT * FROM users WHERE firstname=\{firstName} and lastname=\{lastName} and email=\{email}"; rather than: query = client.prepare("SELECT * FROM users WHERE firstname=? and lastname=? and email=?", firstName, lastName, email);
- kaba0 4y agoThis literally even has examples in the JEP, one can create custom template processors which don’t even have to return a String, but can return a PreparedStatement instead.