mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-25 02:12:22 -05:00
Use expected defaults for primitive types in jdbcmapper
This commit is contained in:
parent
8079ae6aa7
commit
c1b8cfcf3b
@ -2,6 +2,7 @@ package com.moparisthebest.jdbc.codegen;
|
|||||||
|
|
||||||
import com.moparisthebest.jdbc.Finishable;
|
import com.moparisthebest.jdbc.Finishable;
|
||||||
import com.moparisthebest.jdbc.ResultSetMapper;
|
import com.moparisthebest.jdbc.ResultSetMapper;
|
||||||
|
import com.moparisthebest.jdbc.TypeMappingsFactory;
|
||||||
import com.moparisthebest.jdbc.util.ResultSetIterable;
|
import com.moparisthebest.jdbc.util.ResultSetIterable;
|
||||||
|
|
||||||
import javax.annotation.processing.ProcessingEnvironment;
|
import javax.annotation.processing.ProcessingEnvironment;
|
||||||
@ -171,7 +172,12 @@ public class CompileTimeResultSetMapper {
|
|||||||
writeObject(w, keys, returnTypeMirror, cal, reflectionFields);
|
writeObject(w, keys, returnTypeMirror, cal, reflectionFields);
|
||||||
w.write("\t\t\t\treturn ");
|
w.write("\t\t\t\treturn ");
|
||||||
// this does not clean null on purpose, neither does CleaningResultSetMapper
|
// this does not clean null on purpose, neither does CleaningResultSetMapper
|
||||||
clean(w, cleaner).write(";\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n");
|
clean(w, cleaner).write(";\n\t\t\t} else {\n\t\t\t\treturn ");
|
||||||
|
if(returnTypeMirror.getKind().isPrimitive())
|
||||||
|
w.append(TypeMappingsFactory.getInstance().fixNull(typeMirrorToClass(returnTypeMirror)).toString()); // todo: ok, but could be better
|
||||||
|
else
|
||||||
|
w.append("null");
|
||||||
|
w.append(";\n\t\t\t}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toResultSetIterable(final Writer w, final String[] keys, final TypeMirror returnTypeMirror, final String cal, final String cleaner, final boolean closePs, final ReflectionFields reflectionFields) throws IOException, ClassNotFoundException {
|
private void toResultSetIterable(final Writer w, final String[] keys, final TypeMirror returnTypeMirror, final String cal, final String cleaner, final boolean closePs, final ReflectionFields reflectionFields) throws IOException, ClassNotFoundException {
|
||||||
|
@ -48,6 +48,9 @@ public interface PersonDAO extends Closeable {
|
|||||||
@JdbcMapper.SQL("UPDATE person SET first_name = {firstName} WHERE person_no = {personNo}")
|
@JdbcMapper.SQL("UPDATE person SET first_name = {firstName} WHERE person_no = {personNo}")
|
||||||
void setFirstNameBlob(@JdbcMapper.Blob String firstName, long personNo) throws SQLException;
|
void setFirstNameBlob(@JdbcMapper.Blob String firstName, long personNo) throws SQLException;
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
|
||||||
|
long getPersonNo(String lastName) throws SQLException;
|
||||||
|
|
||||||
@JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}")
|
@JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}")
|
||||||
ResultSet getPeopleResultSet(String lastName) throws SQLException;
|
ResultSet getPeopleResultSet(String lastName) throws SQLException;
|
||||||
|
|
||||||
|
@ -48,6 +48,9 @@ public interface PrestoPersonDAO extends PersonDAO {
|
|||||||
@JdbcMapper.SQL("UPDATE person SET first_name = {firstName} WHERE person_no = {personNo}")
|
@JdbcMapper.SQL("UPDATE person SET first_name = {firstName} WHERE person_no = {personNo}")
|
||||||
void setFirstNameBlob(@JdbcMapper.Blob String firstName, long personNo) throws SQLException;
|
void setFirstNameBlob(@JdbcMapper.Blob String firstName, long personNo) throws SQLException;
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
|
||||||
|
long getPersonNo(String lastName) throws SQLException;
|
||||||
|
|
||||||
@JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}")
|
@JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}")
|
||||||
ResultSet getPeopleResultSet(String lastName) throws SQLException;
|
ResultSet getPeopleResultSet(String lastName) throws SQLException;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user