mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-12-12 02:22:16 -05:00
Add support for calling getters/fields on parameters
This commit is contained in:
parent
2795b77584
commit
c99b78691b
@ -23,4 +23,17 @@ public class ReflectionUtil {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T getValue(final Class<?> clazz, final String declaredField, final Class<T> retClazz, final Object obj) {
|
||||||
|
if(obj == null) return null;
|
||||||
|
return getValue(getAccessibleField(clazz, declaredField), retClazz, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getValue(final Field field, final Class<T> retClazz, final Object obj) {
|
||||||
|
try {
|
||||||
|
return retClazz.cast(field.get(obj));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.moparisthebest.jdbc.codegen;
|
||||||
|
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
class DelegatingVariableElement implements VariableElement {
|
||||||
|
|
||||||
|
final VariableElement delegate;
|
||||||
|
|
||||||
|
DelegatingVariableElement(final VariableElement delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getConstantValue() {
|
||||||
|
return delegate.getConstantValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeMirror asType() {
|
||||||
|
return delegate.asType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ElementKind getKind() {
|
||||||
|
return delegate.getKind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends AnnotationMirror> getAnnotationMirrors() {
|
||||||
|
return delegate.getAnnotationMirrors();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A extends Annotation> A getAnnotation(final Class<A> annotationType) {
|
||||||
|
return delegate.getAnnotation(annotationType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Modifier> getModifiers() {
|
||||||
|
return delegate.getModifiers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Name getSimpleName() {
|
||||||
|
return delegate.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Element getEnclosingElement() {
|
||||||
|
return delegate.getEnclosingElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Element> getEnclosedElements() {
|
||||||
|
return delegate.getEnclosedElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
return delegate.equals(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return delegate.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R, P> R accept(final ElementVisitor<R, P> v, final P p) {
|
||||||
|
return delegate.accept(v, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
//IFJAVA8_START
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A extends Annotation> A[] getAnnotationsByType(final Class<A> annotationType) {
|
||||||
|
return delegate.getAnnotationsByType(annotationType);
|
||||||
|
}
|
||||||
|
|
||||||
|
//IFJAVA8_END
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DelegatingVariableElement{" +
|
||||||
|
"delegate=" + delegate +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,6 @@ import javax.lang.model.util.Types;
|
|||||||
import javax.tools.Diagnostic;
|
import javax.tools.Diagnostic;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.sql.Blob;
|
import java.sql.Blob;
|
||||||
import java.sql.Clob;
|
import java.sql.Clob;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -30,7 +29,7 @@ import java.util.stream.Stream;
|
|||||||
import static com.moparisthebest.jdbc.TryClose.tryClose;
|
import static com.moparisthebest.jdbc.TryClose.tryClose;
|
||||||
import static com.moparisthebest.jdbc.codegen.JdbcMapper.DatabaseType.ORACLE;
|
import static com.moparisthebest.jdbc.codegen.JdbcMapper.DatabaseType.ORACLE;
|
||||||
import static com.moparisthebest.jdbc.codegen.JdbcMapper.beanSuffix;
|
import static com.moparisthebest.jdbc.codegen.JdbcMapper.beanSuffix;
|
||||||
import static com.moparisthebest.jdbc.codegen.SpecialVariableElement.SpecialType.SQL;
|
import static com.moparisthebest.jdbc.codegen.SpecialVariableElement.SpecialType.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mopar on 5/24/17.
|
* Created by mopar on 5/24/17.
|
||||||
@ -391,12 +390,20 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
int inListBindParamsIdx = -1;
|
int inListBindParamsIdx = -1;
|
||||||
while (bindParamMatcher.find()) {
|
while (bindParamMatcher.find()) {
|
||||||
final String paramName = bindParamMatcher.group(7);
|
final String paramName = bindParamMatcher.group(7);
|
||||||
final VariableElement bindParam = paramMap.get(paramName);
|
int indexOfFirstPeriod = paramName.indexOf(".");
|
||||||
|
final String paramNameTopLevel;
|
||||||
|
if (indexOfFirstPeriod != -1) {
|
||||||
|
final int indexOfFirstNullSafe = paramName.indexOf("?.");
|
||||||
|
paramNameTopLevel = paramName.substring(0, Math.min(indexOfFirstPeriod, indexOfFirstNullSafe == -1 ? Integer.MAX_VALUE : indexOfFirstNullSafe));
|
||||||
|
} else {
|
||||||
|
paramNameTopLevel = paramName;
|
||||||
|
}
|
||||||
|
final VariableElement bindParam = paramMap.get(paramNameTopLevel);
|
||||||
if (bindParam == null) {
|
if (bindParam == null) {
|
||||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, String.format("@JdbcMapper.SQL sql has bind param '%s' not in method parameter list", paramName), methodElement);
|
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, String.format("@JdbcMapper.SQL sql has bind param '%s' not in method parameter list", paramName), methodElement);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
unusedParams.remove(paramName);
|
unusedParams.remove(paramNameTopLevel);
|
||||||
final String clobBlobSql = bindParamMatcher.group(5);
|
final String clobBlobSql = bindParamMatcher.group(5);
|
||||||
final String inColumnName = bindParamMatcher.group(2);
|
final String inColumnName = bindParamMatcher.group(2);
|
||||||
if (inColumnName == null) {
|
if (inColumnName == null) {
|
||||||
@ -404,13 +411,14 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
// shortcut for Bindable without sql:
|
// shortcut for Bindable without sql:
|
||||||
if (types.isAssignable(bindParam.asType(), bindableType)) {
|
if (types.isAssignable(bindParam.asType(), bindableType)) {
|
||||||
bindParamMatcher.appendReplacement(sb, "REPLACEMEWITHUNQUOTEDQUOTEPLZ + " + paramName + " + REPLACEMEWITHUNQUOTEDQUOTEPLZ");
|
bindParamMatcher.appendReplacement(sb, "REPLACEMEWITHUNQUOTEDQUOTEPLZ + " + paramName + " + REPLACEMEWITHUNQUOTEDQUOTEPLZ");
|
||||||
final SpecialVariableElement sve = new SpecialVariableElement(bindParam, SQL, null);
|
final SpecialVariableElement sve = new SpecialVariableElement(allowReflection, bindParam, paramName, indexOfFirstPeriod, SQL, null);
|
||||||
bindParams.add(sve);
|
bindParams.add(sve);
|
||||||
sqlParam = true;
|
sqlParam = true;
|
||||||
sqlIterableParam |= sve.iterable || sve.bindable;
|
sqlIterableParam |= sve.iterable || sve.bindable;
|
||||||
} else {
|
} else {
|
||||||
bindParamMatcher.appendReplacement(sb, "?");
|
bindParamMatcher.appendReplacement(sb, "?");
|
||||||
bindParams.add(bindParam);
|
bindParams.add(indexOfFirstPeriod == -1 ? bindParam :
|
||||||
|
new SpecialVariableElement(allowReflection, bindParam, paramName, indexOfFirstPeriod, PLAIN));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final String upperClobBlobSql = clobBlobSql.toUpperCase();
|
final String upperClobBlobSql = clobBlobSql.toUpperCase();
|
||||||
@ -419,7 +427,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
blobCharset = blobCharset.substring(0, blobCharset.indexOf(':')).trim();
|
blobCharset = blobCharset.substring(0, blobCharset.indexOf(':')).trim();
|
||||||
if(upperClobBlobSql.startsWith("SQL")) {
|
if(upperClobBlobSql.startsWith("SQL")) {
|
||||||
bindParamMatcher.appendReplacement(sb, "REPLACEMEWITHUNQUOTEDQUOTEPLZ + " + paramName + " + REPLACEMEWITHUNQUOTEDQUOTEPLZ");
|
bindParamMatcher.appendReplacement(sb, "REPLACEMEWITHUNQUOTEDQUOTEPLZ + " + paramName + " + REPLACEMEWITHUNQUOTEDQUOTEPLZ");
|
||||||
final SpecialVariableElement sve = new SpecialVariableElement(bindParam, SQL, blobCharset);
|
final SpecialVariableElement sve = new SpecialVariableElement(allowReflection, bindParam, paramName, indexOfFirstPeriod, SQL, blobCharset);
|
||||||
bindParams.add(sve);
|
bindParams.add(sve);
|
||||||
sqlParam = true;
|
sqlParam = true;
|
||||||
sqlIterableParam |= sve.iterable || sve.bindable;
|
sqlIterableParam |= sve.iterable || sve.bindable;
|
||||||
@ -427,19 +435,19 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
bindParamMatcher.appendReplacement(sb, "?");
|
bindParamMatcher.appendReplacement(sb, "?");
|
||||||
switch (upperClobBlobSql.charAt(0)) {
|
switch (upperClobBlobSql.charAt(0)) {
|
||||||
case 'B':
|
case 'B':
|
||||||
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.BLOB, blobCharset));
|
bindParams.add(new SpecialVariableElement(allowReflection, bindParam, paramName, indexOfFirstPeriod, BLOB, blobCharset));
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
if (blobCharset != null)
|
if (blobCharset != null)
|
||||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "blob character set not valid with clob", bindParam);
|
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "blob character set not valid with clob", bindParam);
|
||||||
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.CLOB));
|
bindParams.add(new SpecialVariableElement(allowReflection, bindParam, paramName, indexOfFirstPeriod, CLOB));
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (blobCharset != null)
|
if (blobCharset != null)
|
||||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "blob character set not valid with str", bindParam);
|
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "blob character set not valid with str", bindParam);
|
||||||
if(upperClobBlobSql.startsWith("STRB")) // side-effect of regex matching...
|
if(upperClobBlobSql.startsWith("STRB")) // side-effect of regex matching...
|
||||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "special variable type can only be clob/blob/str/sql, not " + clobBlobSql, bindParam);
|
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "special variable type can only be clob/blob/str/sql, not " + clobBlobSql, bindParam);
|
||||||
bindParams.add(new SpecialVariableElement(bindParam, SpecialVariableElement.SpecialType.STR_BOOLEAN));
|
bindParams.add(new SpecialVariableElement(allowReflection, bindParam, paramName, indexOfFirstPeriod, STR_BOOLEAN));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -451,8 +459,8 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "cannot combine in/not in and clob/blob/str/sql", bindParam);
|
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "cannot combine in/not in and clob/blob/str/sql", bindParam);
|
||||||
SpecialVariableElement inListBindParam = inListBindParams.get(paramName);
|
SpecialVariableElement inListBindParam = inListBindParams.get(paramName);
|
||||||
if(inListBindParam == null) {
|
if(inListBindParam == null) {
|
||||||
inListBindParam = new SpecialVariableElement(bindParam,
|
inListBindParam = new SpecialVariableElement(allowReflection, bindParam, paramName, indexOfFirstPeriod,
|
||||||
databaseType == JdbcMapper.DatabaseType.BIND ? SpecialVariableElement.SpecialType.BIND_IN_LIST : SpecialVariableElement.SpecialType.IN_LIST,
|
databaseType == JdbcMapper.DatabaseType.BIND ? BIND_IN_LIST : IN_LIST,
|
||||||
++inListBindParamsIdx);
|
++inListBindParamsIdx);
|
||||||
//IFJAVA8_START
|
//IFJAVA8_START
|
||||||
if(databaseType == JdbcMapper.DatabaseType.BIND) {
|
if(databaseType == JdbcMapper.DatabaseType.BIND) {
|
||||||
@ -981,9 +989,10 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
// special behavior
|
// special behavior
|
||||||
if (param instanceof SpecialVariableElement) {
|
if (param instanceof SpecialVariableElement) {
|
||||||
final SpecialVariableElement specialParam = (SpecialVariableElement) param;
|
final SpecialVariableElement specialParam = (SpecialVariableElement) param;
|
||||||
|
variableName = specialParam.getName();
|
||||||
switch (specialParam.specialType) {
|
switch (specialParam.specialType) {
|
||||||
case BIND_IN_LIST: {
|
case BIND_IN_LIST: {
|
||||||
w.append("for(final ").append(specialParam.getComponentTypeString()).append(" _bindInListParam : ").append(specialParam.getName()).append(")\n");
|
w.append("for(final ").append(specialParam.getComponentTypeString()).append(" _bindInListParam : ").append(variableName).append(")\n");
|
||||||
w.append("\t\t\t\tps.setObject(").append(index).append(", _bindInListParam);\n");
|
w.append("\t\t\t\tps.setObject(").append(index).append(", _bindInListParam);\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1109,7 +1118,7 @@ public class JdbcMapperProcessor extends AbstractProcessor {
|
|||||||
method = "Ref";
|
method = "Ref";
|
||||||
} else {
|
} else {
|
||||||
// shouldn't get here ever, if we do the types should be more specific
|
// shouldn't get here ever, if we do the types should be more specific
|
||||||
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@JdbcMapper.SQL could not properly infer PreparedStatement bind call for param: " + variableName, param);
|
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@JdbcMapper.SQL could not properly infer PreparedStatement bind call for param: " + variableName + ", type: " + o, param instanceof SpecialVariableElement ? ((SpecialVariableElement)param).delegate : param);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
w.write("ps.set");
|
w.write("ps.set");
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
package com.moparisthebest.jdbc.codegen;
|
package com.moparisthebest.jdbc.codegen;
|
||||||
|
|
||||||
import javax.lang.model.element.*;
|
import javax.lang.model.element.*;
|
||||||
|
import javax.lang.model.type.DeclaredType;
|
||||||
|
import javax.lang.model.type.TypeKind;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
import java.lang.annotation.Annotation;
|
import javax.tools.Diagnostic;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Set;
|
|
||||||
|
import static com.moparisthebest.jdbc.codegen.CompileTimeRowToObjectMapper.getAllImplementedTypes;
|
||||||
|
import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.booleanType;
|
||||||
|
import static com.moparisthebest.jdbc.codegen.JdbcMapperProcessor.types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mopar on 6/1/17.
|
* Created by mopar on 6/1/17.
|
||||||
*/
|
*/
|
||||||
class SpecialVariableElement implements VariableElement {
|
class SpecialVariableElement extends DelegatingVariableElement {
|
||||||
|
|
||||||
enum SpecialType {
|
enum SpecialType {
|
||||||
BIND_IN_LIST,
|
BIND_IN_LIST,
|
||||||
@ -18,36 +23,172 @@ class SpecialVariableElement implements VariableElement {
|
|||||||
BLOB,
|
BLOB,
|
||||||
SQL,
|
SQL,
|
||||||
STR_BOOLEAN,
|
STR_BOOLEAN,
|
||||||
|
PLAIN,
|
||||||
}
|
}
|
||||||
|
|
||||||
final VariableElement delegate;
|
|
||||||
final SpecialType specialType;
|
final SpecialType specialType;
|
||||||
final String blobStringCharset;
|
final String blobStringCharset;
|
||||||
final int index;
|
final int index;
|
||||||
final boolean iterable, bindable;
|
final boolean iterable, bindable, allowReflection;
|
||||||
|
|
||||||
|
TypeMirror type;
|
||||||
|
|
||||||
String name, componentTypeString;
|
String name, componentTypeString;
|
||||||
|
|
||||||
SpecialVariableElement(final VariableElement delegate, final SpecialType specialType) {
|
SpecialVariableElement(final boolean allowReflection, final VariableElement delegate, final String paramName, final int indexOfFirstPeriod, final SpecialType specialType) {
|
||||||
this(delegate, specialType, null, 0);
|
this(allowReflection, delegate, paramName, indexOfFirstPeriod, specialType, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialVariableElement(final VariableElement delegate, final SpecialType specialType, final int index) {
|
SpecialVariableElement(final boolean allowReflection, final VariableElement delegate, final String paramName, final int indexOfFirstPeriod, final SpecialType specialType, final int index) {
|
||||||
this(delegate, specialType, null, index);
|
this(allowReflection, delegate, paramName, indexOfFirstPeriod, specialType, null, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialVariableElement(final VariableElement delegate, final SpecialType specialType, final String blobStringCharset) {
|
SpecialVariableElement(final boolean allowReflection, final VariableElement delegate, final String paramName, final int indexOfFirstPeriod, final SpecialType specialType, final String blobStringCharset) {
|
||||||
this(delegate, specialType, blobStringCharset, 0);
|
this(allowReflection, delegate, paramName, indexOfFirstPeriod, specialType, blobStringCharset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialVariableElement(final VariableElement delegate, final SpecialType specialType, final String blobStringCharset, final int index) {
|
SpecialVariableElement(final boolean allowReflection, final VariableElement delegate, final String paramName, final int indexOfPeriod, final SpecialType specialType, final String blobStringCharset, final int index) {
|
||||||
this.delegate = delegate;
|
super(delegate);
|
||||||
|
this.allowReflection = allowReflection;
|
||||||
this.specialType = specialType;
|
this.specialType = specialType;
|
||||||
this.blobStringCharset = blobStringCharset;
|
this.blobStringCharset = blobStringCharset;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.name = getSimpleName().toString();
|
if(indexOfPeriod == -1) {
|
||||||
this.iterable = specialType == SpecialType.SQL && JdbcMapperProcessor.types.isAssignable(delegate.asType(), JdbcMapperProcessor.iterableType);
|
// no recursion or anything complicated, straight parameter
|
||||||
this.bindable = !this.iterable && specialType == SpecialType.SQL && JdbcMapperProcessor.types.isAssignable(delegate.asType(), JdbcMapperProcessor.bindableType);
|
this.name = paramName;
|
||||||
|
this.type = delegate.asType();
|
||||||
|
} else {
|
||||||
|
final String[] paramSplit = paramName.split("\\s*\\.\\s*");
|
||||||
|
if(paramSplit.length < 2) {
|
||||||
|
JdbcMapperProcessor.messager.printMessage(Diagnostic.Kind.ERROR, "paramName invalid with period at end: " + paramName, delegate);
|
||||||
|
throw new RuntimeException("paramName invalid with period at end: " + paramName);
|
||||||
|
}
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
appendVar(paramSplit[0], sb);
|
||||||
|
this.type = delegate.asType();
|
||||||
|
for(int x = 1; x < paramSplit.length; ++x) {
|
||||||
|
appendVar(paramSplit[x], sb);
|
||||||
|
}
|
||||||
|
this.name = sb.toString();
|
||||||
|
}
|
||||||
|
this.iterable = specialType == SpecialType.SQL && types.isAssignable(delegate.asType(), JdbcMapperProcessor.iterableType);
|
||||||
|
this.bindable = !this.iterable && specialType == SpecialType.SQL && types.isAssignable(delegate.asType(), JdbcMapperProcessor.bindableType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appendVar(final String fullParam, final StringBuilder sb) {
|
||||||
|
final boolean nullSafe = fullParam.endsWith("?");
|
||||||
|
final String param = nullSafe ? fullParam.substring(0, fullParam.length() - 1) : fullParam;
|
||||||
|
// hack for first param
|
||||||
|
if(type != null) {
|
||||||
|
final String name = getGetterTypeAppendString(param, sb);
|
||||||
|
if(name == null) {
|
||||||
|
JdbcMapperProcessor.messager.printMessage(Diagnostic.Kind.ERROR, "recursive param not found: " + param, delegate);
|
||||||
|
}
|
||||||
|
sb.append(name);
|
||||||
|
} else {
|
||||||
|
sb.append(param);
|
||||||
|
}
|
||||||
|
if (nullSafe) {
|
||||||
|
final String var = sb.toString();
|
||||||
|
sb.setLength(0);
|
||||||
|
sb.append("((").append(var).append(") == null ? null : (").append(var).append("))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGetterTypeAppendString(final String fieldName, final StringBuilder sb) {
|
||||||
|
|
||||||
|
if(type.getKind() != TypeKind.DECLARED) {
|
||||||
|
JdbcMapperProcessor.messager.printMessage(Diagnostic.Kind.ERROR, "type " + type + " not TypeKind.DECLARED ?? how?? fieldName: " + fieldName, delegate);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
final DeclaredType declaredReturnType = (DeclaredType) type;
|
||||||
|
|
||||||
|
final List<DeclaredType> allTypes = getAllImplementedTypes(declaredReturnType, new ArrayList<DeclaredType>());
|
||||||
|
|
||||||
|
// public methods
|
||||||
|
// have to loop to get super methods too
|
||||||
|
final String methodSuffix = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
|
||||||
|
final String getMethodName = "get" + methodSuffix, isMethodName = "is" + methodSuffix;
|
||||||
|
for (final DeclaredType clazz : allTypes) {
|
||||||
|
for (Element e : ((TypeElement) clazz.asElement()).getEnclosedElements()) {
|
||||||
|
if (e.getKind() != ElementKind.METHOD)
|
||||||
|
continue;
|
||||||
|
final ExecutableElement m = (ExecutableElement) e;
|
||||||
|
//System.out.printf("method: '%s', isSetterMethod: '%s'\n", m, isSetterMethod(m));
|
||||||
|
final String ret = matchingGetterMethod(m, getMethodName, isMethodName);
|
||||||
|
if(ret != null) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix for 8813: include inherited and non-public fields
|
||||||
|
for (final DeclaredType clazz : allTypes) {
|
||||||
|
//System.out.println("fields in class: "+Arrays.toString(classFields));
|
||||||
|
for (Element e : ((TypeElement)clazz.asElement()).getEnclosedElements()) {
|
||||||
|
if(e.getKind() != ElementKind.FIELD)
|
||||||
|
continue;
|
||||||
|
final VariableElement f = (VariableElement)e;
|
||||||
|
final Set<Modifier> modifiers = f.getModifiers();
|
||||||
|
// we want the name to match exactly
|
||||||
|
if(!fieldName.equals(f.getSimpleName().toString())) continue;
|
||||||
|
// cannot be static
|
||||||
|
if (modifiers.contains(Modifier.STATIC)) return null;
|
||||||
|
// must be public todo: what about package-private?
|
||||||
|
if (modifiers.contains(Modifier.PUBLIC)) {
|
||||||
|
this.type = f.asType();
|
||||||
|
return "." + fieldName;
|
||||||
|
}
|
||||||
|
if(!allowReflection) {
|
||||||
|
JdbcMapperProcessor.messager.printMessage(Diagnostic.Kind.ERROR, "cannot public setter, but did find non-public field on parameter: '" + delegate.getSimpleName() + "' with this name: '" + fieldName + "', but reflection is not allowed", delegate);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
// otherwise support terrible reflection
|
||||||
|
final TypeMirror oldType = this.type;
|
||||||
|
this.type = f.asType();
|
||||||
|
final String obj = sb.toString();
|
||||||
|
sb.setLength(0);
|
||||||
|
return "com.moparisthebest.jdbc.util.ReflectionUtil.getValue(" + oldType.toString() + ".class, \"" + fieldName + "\", " +
|
||||||
|
this.type.toString() + ".class, (" + obj + "))";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JdbcMapperProcessor.messager.printMessage(Diagnostic.Kind.ERROR, "cannot find field or public setter on parameter: '" + delegate.getSimpleName() + "' with this name: '" + fieldName + "'", delegate);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the given method is a java bean setter method.
|
||||||
|
* @param method Method to check
|
||||||
|
* @param getMethodName
|
||||||
|
* @param isMethodName
|
||||||
|
* @return True if the method is a setter method.
|
||||||
|
*/
|
||||||
|
public String matchingGetterMethod(final ExecutableElement method, final String getMethodName, final String isMethodName) {
|
||||||
|
final String methodName = method.getSimpleName().toString();
|
||||||
|
final boolean isMethod = isMethodName.equals(methodName);
|
||||||
|
if (isMethod || getMethodName.equals(methodName)) {
|
||||||
|
|
||||||
|
final Set<Modifier> modifiers = method.getModifiers();
|
||||||
|
// cannot be static
|
||||||
|
if (modifiers.contains(Modifier.STATIC)) return null;
|
||||||
|
// must be public todo: what about package-private?
|
||||||
|
if (!modifiers.contains(Modifier.PUBLIC)) return null;
|
||||||
|
|
||||||
|
// must take no parameters
|
||||||
|
if (method.getParameters().size() != 0) return null;
|
||||||
|
|
||||||
|
final TypeMirror ret = method.getReturnType();
|
||||||
|
|
||||||
|
// must return boolean/Boolean to qualify for is*
|
||||||
|
if(isMethod && !(ret.getKind() == TypeKind.BOOLEAN || types.isAssignable(ret, booleanType))) return null;
|
||||||
|
|
||||||
|
this.type = ret;
|
||||||
|
return "." + methodName + "()";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -66,75 +207,11 @@ class SpecialVariableElement implements VariableElement {
|
|||||||
this.componentTypeString = componentTypeString;
|
this.componentTypeString = componentTypeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getConstantValue() {
|
|
||||||
return delegate.getConstantValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeMirror asType() {
|
public TypeMirror asType() {
|
||||||
return delegate.asType();
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ElementKind getKind() {
|
|
||||||
return delegate.getKind();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends AnnotationMirror> getAnnotationMirrors() {
|
|
||||||
return delegate.getAnnotationMirrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <A extends Annotation> A getAnnotation(final Class<A> annotationType) {
|
|
||||||
return delegate.getAnnotation(annotationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Modifier> getModifiers() {
|
|
||||||
return delegate.getModifiers();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Name getSimpleName() {
|
|
||||||
return delegate.getSimpleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Element getEnclosingElement() {
|
|
||||||
return delegate.getEnclosingElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Element> getEnclosedElements() {
|
|
||||||
return delegate.getEnclosedElements();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object obj) {
|
|
||||||
return delegate.equals(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return delegate.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, P> R accept(final ElementVisitor<R, P> v, final P p) {
|
|
||||||
return delegate.accept(v, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
//IFJAVA8_START
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <A extends Annotation> A[] getAnnotationsByType(final Class<A> annotationType) {
|
|
||||||
return delegate.getAnnotationsByType(annotationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
//IFJAVA8_END
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SpecialVariableElement{" +
|
return "SpecialVariableElement{" +
|
||||||
|
@ -43,6 +43,12 @@ public class ParamPatternTest {
|
|||||||
testMatch("{str:comment}", s(null, null, null, null, "str:", null, "comment"));
|
testMatch("{str:comment}", s(null, null, null, null, "str:", null, "comment"));
|
||||||
testMatch("{str: comment}", s(null, null, null, null, "str: ", null, "comment"));
|
testMatch("{str: comment}", s(null, null, null, null, "str: ", null, "comment"));
|
||||||
testMatch("{str : comment}", s(null, null, null, null, "str : ", null, "comment"));
|
testMatch("{str : comment}", s(null, null, null, null, "str : ", null, "comment"));
|
||||||
|
|
||||||
|
testMatch("{dto.personNo}", s(null, null, null, null, null, null, "dto.personNo"));
|
||||||
|
testMatch("{dto.subclass1.personNo}", s(null, null, null, null, null, null, "dto.subclass1.personNo"));
|
||||||
|
testMatch("{dto?.personNo}", s(null, null, null, null, null, null, "dto?.personNo"));
|
||||||
|
testMatch("{dto?.subclass1.personNo}", s(null, null, null, null, null, null, "dto?.subclass1.personNo"));
|
||||||
|
testMatch("{dto?.subclass1?.personNo}", s(null, null, null, null, null, null, "dto?.subclass1?.personNo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testMatch(final String sql, final Collection<String[]> expected) {
|
private static void testMatch(final String sql, final Collection<String[]> expected) {
|
||||||
|
@ -32,6 +32,15 @@ public interface PersonDAO extends JdbcMapper {
|
|||||||
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
||||||
int insertPerson(long personNo, Date birthDate, String firstName, String lastName);
|
int insertPerson(long personNo, Date birthDate, String firstName, String lastName);
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({person.personNo}, {person.birthDate}, {person.firstName}, {person.lastName})")
|
||||||
|
int insertPerson(FieldPerson person);
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({person.subClass1.subClass2.subClass3.personNo}, {person.subClass1.subClass2.subClass3.birthDate}, {person.firstName}, {person.subClass1.subClass2.subClass3.lastName})")
|
||||||
|
int insertPublicFieldDto(PublicFieldDto person);
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({person?.subClass1?.subClass2?.subClass3?.personNo}, {person?.subClass1?.subClass2?.subClass3?.birthDate}, {person.firstName}, {person?.subClass1?.subClass2?.subClass3?.lastName})")
|
||||||
|
int insertPublicFieldDtoNullSafe(PublicFieldDto person);
|
||||||
|
|
||||||
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
||||||
long insertPersonGeneratedKey(long personNo, Date birthDate, String firstName, String lastName);
|
long insertPersonGeneratedKey(long personNo, Date birthDate, String firstName, String lastName);
|
||||||
|
|
||||||
|
@ -32,6 +32,15 @@ public interface PrestoPersonDAO extends PersonDAO {
|
|||||||
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
||||||
int insertPerson(long personNo, Date birthDate, String firstName, String lastName);
|
int insertPerson(long personNo, Date birthDate, String firstName, String lastName);
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({person.personNo}, {person.birthDate}, {person.firstName}, {person.lastName})")
|
||||||
|
int insertPerson(FieldPerson person);
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({person.subClass1.subClass2.subClass3.personNo}, {person.subClass1.subClass2.subClass3.birthDate}, {person.firstName}, {person.subClass1.subClass2.subClass3.lastName})")
|
||||||
|
int insertPublicFieldDto(PublicFieldDto person);
|
||||||
|
|
||||||
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({person?.subClass1?.subClass2?.subClass3?.personNo}, {person?.subClass1?.subClass2?.subClass3?.birthDate}, {person.firstName}, {person?.subClass1?.subClass2?.subClass3?.lastName})")
|
||||||
|
int insertPublicFieldDtoNullSafe(PublicFieldDto person);
|
||||||
|
|
||||||
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
@JdbcMapper.SQL("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES ({personNo}, {birthDate}, {firstName}, {lastName})")
|
||||||
long insertPersonGeneratedKey(long personNo, Date birthDate, String firstName, String lastName);
|
long insertPersonGeneratedKey(long personNo, Date birthDate, String firstName, String lastName);
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.moparisthebest.jdbc.dto;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class PublicFieldDto {
|
||||||
|
public String firstName;
|
||||||
|
public SubClass1 subClass1;
|
||||||
|
|
||||||
|
public static class SubClass1 {
|
||||||
|
public SubClass2 subClass2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SubClass2 {
|
||||||
|
public SubClass3 subClass3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SubClass3 {
|
||||||
|
private long personNo;
|
||||||
|
public Date birthDate;
|
||||||
|
public String lastName;
|
||||||
|
}
|
||||||
|
}
|
@ -64,6 +64,57 @@ public class PersonDAOAnyBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOBindBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOOracleBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOUnNestBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOAnyBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOBindBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOOracleBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
@ -64,6 +64,57 @@ public class PersonDAOUnNestBean implements PersonDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPerson(final com.moparisthebest.jdbc.dto.FieldPerson person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, person.getPersonNo());
|
||||||
|
ps.setObject(2, person.getBirthDate() == null ? null : new java.sql.Timestamp(person.getBirthDate().getTime()));
|
||||||
|
ps.setObject(3, person.getFirstName());
|
||||||
|
ps.setObject(4, person.getLastName());
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDto(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (person.subClass1.subClass2.subClass3)));
|
||||||
|
ps.setObject(2, person.subClass1.subClass2.subClass3.birthDate == null ? null : new java.sql.Timestamp(person.subClass1.subClass2.subClass3.birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, person.subClass1.subClass2.subClass3.lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPublicFieldDtoNullSafe(final com.moparisthebest.jdbc.dto.PublicFieldDto person) {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
ps = conn.prepareStatement("INSERT INTO person (person_no, birth_date, last_name, first_name) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setObject(1, com.moparisthebest.jdbc.util.ReflectionUtil.getValue(com.moparisthebest.jdbc.dto.PublicFieldDto.SubClass3.class, "personNo", long.class, (((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)))));
|
||||||
|
ps.setObject(2, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate == null ? null : new java.sql.Timestamp(((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).birthDate.getTime()));
|
||||||
|
ps.setObject(3, person.firstName);
|
||||||
|
ps.setObject(4, ((((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3) == null ? null : (((((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2) == null ? null : (((((person) == null ? null : (person)).subClass1) == null ? null : (((person) == null ? null : (person)).subClass1)).subClass2)).subClass3)).lastName);
|
||||||
|
return ps.executeUpdate();
|
||||||
|
} catch(SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
tryClose(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
public long insertPersonGeneratedKey(final long personNo, final java.util.Date birthDate, final java.lang.String firstName, final java.lang.String lastName) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user