Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.mybatis.generator.codegen.AbstractGenerator;
import org.mybatis.generator.codegen.mybatis3.ListUtilities;
import org.mybatis.generator.config.GeneratedKey;
import org.mybatis.generator.internal.util.StringUtility;

public abstract class AbstractJavaMapperMethodGenerator extends AbstractGenerator {
public abstract void addInterfaceElements(Interface interfaze);
Expand Down Expand Up @@ -97,7 +98,9 @@ private String buildGeneratedKeyAnnotation(GeneratedKey gk, IntrospectedColumn i
if (gk.isJdbcStandard()) {
sb.append("@Options(useGeneratedKeys=true,keyProperty=\""); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\")"); //$NON-NLS-1$
sb.append("\""); //$NON-NLS-1$
sb.append(String.format(", keyColumn=\"%s\"", Optional.ofNullable(gk.getColumn()).map(StringUtility::escapeStringForJava).orElse(""))); //$NON-NLS-1$ $NON-NLS-2$
sb.append(")"); //$NON-NLS-1$
} else {
sb.append("@SelectKey(statement=\""); //$NON-NLS-1$
sb.append(gk.getRuntimeSqlStatement());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

Expand All @@ -32,6 +33,7 @@
import org.mybatis.generator.codegen.mybatis3.ListUtilities;
import org.mybatis.generator.config.GeneratedKey;
import org.mybatis.generator.internal.util.JavaBeansUtil;
import org.mybatis.generator.internal.util.StringUtility;

public class FragmentGenerator {

Expand Down Expand Up @@ -246,7 +248,9 @@ public MethodParts getGeneratedKeyAnnotation(GeneratedKey gk) {
builder.withImport(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Options")); //$NON-NLS-1$
sb.append("@Options(useGeneratedKeys=true,keyProperty=\"row."); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\")"); //$NON-NLS-1$
sb.append("\""); //$NON-NLS-1$
sb.append(String.format(", keyColumn=\"%s\"", Optional.ofNullable(gk.getColumn()).map(StringUtility::escapeStringForJava).orElse(""))); //$NON-NLS-1$ $NON-NLS-2$
sb.append(")"); //$NON-NLS-1$
} else {
builder.withImport(new FullyQualifiedJavaType("org.apache.ibatis.annotations.SelectKey")); //$NON-NLS-1$
FullyQualifiedJavaType fqjt = introspectedColumn.getFullyQualifiedJavaType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.mybatis.generator.api.IntrospectedColumn;
Expand All @@ -31,6 +32,7 @@
import org.mybatis.generator.api.dom.kotlin.KotlinArg;
import org.mybatis.generator.codegen.mybatis3.ListUtilities;
import org.mybatis.generator.config.GeneratedKey;
import org.mybatis.generator.internal.util.StringUtility;
import org.mybatis.generator.runtime.kotlin.KotlinDynamicSqlSupportClassGenerator;

public class KotlinFragmentGenerator {
Expand Down Expand Up @@ -187,7 +189,9 @@ public KotlinFunctionParts getGeneratedKeyAnnotation(GeneratedKey gk) {
builder.withImport("org.apache.ibatis.annotations.Options"); //$NON-NLS-1$
sb.append("@Options(useGeneratedKeys=true,keyProperty=\"row."); //$NON-NLS-1$
sb.append(introspectedColumn.getJavaProperty());
sb.append("\")"); //$NON-NLS-1$
sb.append("\""); //$NON-NLS-1$
sb.append(String.format(", keyColumn=\"%s\"", Optional.ofNullable(gk.getColumn()).map(StringUtility::escapeStringForKotlin).orElse(""))); //$NON-NLS-1$ $NON-NLS-2$
sb.append(")"); //$NON-NLS-1$
builder.withAnnotation(sb.toString());
} else {
builder.withImport("org.apache.ibatis.annotations.SelectKey"); //$NON-NLS-1$
Expand Down