类org.apache.ibatis.annotations.SelectKey源码实例Demo

下面列出了怎么用org.apache.ibatis.annotations.SelectKey的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hmdm-server   文件: PostgresDeviceLogMapper.java
@Insert("INSERT INTO plugin_devicelog_settings_rules (" +
        "  settingId, " +
        "  name, " +
        "  active, " +
        "  applicationId, " +
        "  severity, " +
        "  filter, " +
        "  groupId, " +
        "  configurationId " +
        ") " +
        "VALUES (" +
        "  #{settingId}, " +
        "  #{name}, " +
        "  #{active}, " +
        "  #{applicationId}, " +
        "  #{severity}, " +
        "  #{filter}, " +
        "  #{groupId}, " +
        "  #{configurationId} " +
        ")")
@SelectKey( statement = "SELECT currval('plugin_devicelog_settings_rules_id_seq')",
        keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
void insertPluginSettingsRule(PostgresDeviceLogRule rule);
 
源代码2 项目: Java-API-Test-Examples   文件: CoffeeMapper.java
/**
 * This method was generated by MyBatis Generator.
 * This method corresponds to the database table T_COFFEE
 *
 * @mbg.generated Sun Dec 08 00:33:16 CST 2019
 */
@Insert({
    "insert into T_COFFEE (NAME, PRICE, ",
    "CREATE_TIME, UPDATE_TIME)",
    "values (#{name,jdbcType=VARCHAR}, #{price,jdbcType=BIGINT,typeHandler=com.zuozewei.springbootdatadrivendemo.handler.MoneyTypeHandler}, ",
    "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})"
})
@SelectKey(statement="CALL IDENTITY()", keyProperty="id", before=false, resultType=Long.class)
int insert(Coffee record);
 
源代码3 项目: Java-API-Test-Examples   文件: CoffeeMapper.java
/**
 * This method was generated by MyBatis Generator.
 * This method corresponds to the database table t_coffee
 *
 * @mbg.generated Mon Dec 16 18:17:01 CST 2019
 */
@Insert({
    "insert into t_coffee (name, price, ",
    "create_time, update_time)",
    "values (#{name,jdbcType=VARCHAR}, #{price,jdbcType=BIGINT,typeHandler=com.zuozewei.springbootdatabackuprecoverydemo.handler.MoneyTypeHandler}, ",
    "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})"
})
@SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
int insert(Coffee record);
 
源代码4 项目: mybaties   文件: MapperAnnotationBuilder.java
private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
  String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
  Class<?> resultTypeClass = selectKeyAnnotation.resultType();
  StatementType statementType = selectKeyAnnotation.statementType();
  String keyProperty = selectKeyAnnotation.keyProperty();
  String keyColumn = selectKeyAnnotation.keyColumn();
  boolean executeBefore = selectKeyAnnotation.before();

  // defaults
  boolean useCache = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = buildSqlSourceFromStrings(selectKeyAnnotation.statement(), parameterTypeClass, languageDriver);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  assistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType, fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass, resultSetTypeEnum,
      flushCache, useCache, false,
      keyGenerator, keyProperty, keyColumn, null, languageDriver, null);

  id = assistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
  configuration.addKeyGenerator(id, answer);
  return answer;
}
 
源代码5 项目: mybatis   文件: MapperAnnotationBuilder.java
private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
  String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
  Class<?> resultTypeClass = selectKeyAnnotation.resultType();
  StatementType statementType = selectKeyAnnotation.statementType();
  String keyProperty = selectKeyAnnotation.keyProperty();
  String keyColumn = selectKeyAnnotation.keyColumn();
  boolean executeBefore = selectKeyAnnotation.before();

  // defaults
  boolean useCache = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = buildSqlSourceFromStrings(selectKeyAnnotation.statement(), parameterTypeClass, languageDriver);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  assistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType, fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass, resultSetTypeEnum,
      flushCache, useCache, false,
      keyGenerator, keyProperty, keyColumn, null, languageDriver, null);

  id = assistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
  configuration.addKeyGenerator(id, answer);
  return answer;
}
 
源代码6 项目: hmdm-server   文件: CustomerMapper.java
@Insert({"INSERT INTO customers (name, description, filesDir, master, prefix, registrationTime) " +
        "VALUES (#{name}, #{description}, #{filesDir}, FALSE, #{prefix}, #{registrationTime})"})
@SelectKey( statement = "SELECT currval('customers_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
void insert(Customer customer);
 
源代码7 项目: hmdm-server   文件: ApplicationMapper.java
@Insert({"INSERT INTO applications (name, pkg, showIcon, system, customerId, runAfterInstall, runAtBoot, type, iconText, iconId) " +
        "VALUES (#{name}, #{pkg}, #{showIcon}, #{system}, #{customerId}, #{runAfterInstall}, #{runAtBoot}, #{type}, #{iconText}, #{iconId})"})
@SelectKey( statement = "SELECT currval('applications_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
void insertApplication(Application application);
 
源代码8 项目: hmdm-server   文件: ApplicationMapper.java
@Insert({"INSERT INTO applicationVersions (applicationId, version, url) " +
        "VALUES (#{applicationId}, #{version}, #{url})"})
@SelectKey( statement = "SELECT currval('applicationVersions_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
int insertApplicationVersion(ApplicationVersion version);
 
源代码9 项目: hmdm-server   文件: UserMapper.java
@Insert({"INSERT INTO users (login, email, name, password, customerId, userRoleId, allDevicesAvailable) " +
        "VALUES (#{login}, #{email}, #{name}, #{password}, #{customerId}, #{userRole.id}, #{allDevicesAvailable})"})
@SelectKey( statement = "SELECT currval('users_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
void insert(User user);
 
源代码10 项目: hmdm-server   文件: IconMapper.java
@Insert("INSERT INTO icons (customerId, name, fileId) VALUES (#{customerId}, #{name}, #{fileId})")
@SelectKey(statement = "SELECT currval('icons_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class)
int insertIcon(Icon icon);
 
源代码11 项目: hmdm-server   文件: ConfigurationMapper.java
@SelectKey( statement = "SELECT currval('configurations_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
void insertConfiguration(Configuration configuration);
 
源代码12 项目: hmdm-server   文件: UploadedFileMapper.java
@Insert("INSERT INTO uploadedFiles (customerId, filePath, uploadTime) VALUES (#{customerId}, #{filePath}, EXTRACT(EPOCH FROM NOW()) * 1000)")
@SelectKey(statement = "SELECT currval('uploadedFiles_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class)
int insertFile(UploadedFile file);
 
源代码13 项目: hmdm-server   文件: NotificationMapper.java
@Insert("INSERT INTO pushMessages (messageType, deviceId, payload) " +
        "VALUES (#{messageType}, #{deviceId}, #{payload})")
@SelectKey( statement = "SELECT currval('pushmessages_id_seq')", keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
void insertPushMessage(PushMessage message);
 
源代码14 项目: hmdm-server   文件: PostgresDeviceLogMapper.java
@Insert("INSERT INTO plugin_devicelog_settings (customerId, logsPreservePeriod) " +
        "VALUES (#{customerId}, #{logsPreservePeriod})")
@SelectKey( statement = "SELECT currval('plugin_devicelog_settings_id_seq')",
        keyColumn = "id", keyProperty = "id", before = false, resultType = int.class )
void insertPluginSettings(PostgresDeviceLogPluginSettings postgresDeviceLogPluginSettings);
 
源代码15 项目: mybaties   文件: AnnotatedMapper.java
@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="call identity()", keyProperty="nameId", before=false, resultType=int.class)
int insertTable2(Name name);
 
源代码16 项目: mybaties   文件: AnnotatedMapper.java
@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="select id, name_fred from table2 where id = identity()", keyProperty="nameId,generatedName", keyColumn="ID,NAME_FRED", before=false, resultType=Map.class)
int insertTable2WithSelectKeyWithKeyMap(Name name);
 
源代码17 项目: mybaties   文件: AnnotatedMapper.java
@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="select id as nameId, name_fred as generatedName from table2 where id = identity()", keyProperty="nameId,generatedName", before=false, resultType=Name.class)
int insertTable2WithSelectKeyWithKeyObject(Name name);
 
源代码18 项目: mybaties   文件: AnnotatedMapper.java
@Insert("insert into table3 (id, name) values(#{nameId}, #{name})")
@SelectKey(statement="call next value for TestSequence", keyProperty="nameId", before=true, resultType=int.class)
int insertTable3(Name name);
 
源代码19 项目: mybaties   文件: AnnotatedMapper.java
@InsertProvider(type=SqlProvider.class,method="insertTable3_2")
@SelectKey(statement="call next value for TestSequence", keyProperty="nameId", before=true, resultType=int.class)
int insertTable3_2(Name name);
 
源代码20 项目: mybaties   文件: AnnotatedMapper.java
@Update("update table2 set name = #{name} where id = #{nameId}")
@SelectKey(statement="select name_fred from table2 where id = #{nameId}", keyProperty="generatedName", keyColumn="NAME_FRED", before=false, resultType=String.class)
int updateTable2WithSelectKeyWithKeyMap(Name name);
 
源代码21 项目: mybaties   文件: AnnotatedMapper.java
@Update("update table2 set name = #{name} where id = #{nameId}")
@SelectKey(statement="select name_fred as generatedName from table2 where id = #{nameId}", keyProperty="generatedName", before=false, resultType=Name.class)
int updateTable2WithSelectKeyWithKeyObject(Name name);
 
源代码22 项目: mybatis   文件: AnnotatedMapper.java
@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="call identity()", keyProperty="nameId", before=false, resultType=int.class)
int insertTable2(Name name);
 
源代码23 项目: mybatis   文件: AnnotatedMapper.java
@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="select id, name_fred from table2 where id = identity()", keyProperty="nameId,generatedName", keyColumn="ID,NAME_FRED", before=false, resultType=Map.class)
int insertTable2WithSelectKeyWithKeyMap(Name name);
 
源代码24 项目: mybatis   文件: AnnotatedMapper.java
@Insert("insert into table2 (name) values(#{name})")
@SelectKey(statement="select id as nameId, name_fred as generatedName from table2 where id = identity()", keyProperty="nameId,generatedName", before=false, resultType=Name.class)
int insertTable2WithSelectKeyWithKeyObject(Name name);
 
源代码25 项目: mybatis   文件: AnnotatedMapper.java
@Insert("insert into table3 (id, name) values(#{nameId}, #{name})")
@SelectKey(statement="call next value for TestSequence", keyProperty="nameId", before=true, resultType=int.class)
int insertTable3(Name name);
 
源代码26 项目: mybatis   文件: AnnotatedMapper.java
@InsertProvider(type=SqlProvider.class,method="insertTable3_2")
@SelectKey(statement="call next value for TestSequence", keyProperty="nameId", before=true, resultType=int.class)
int insertTable3_2(Name name);
 
源代码27 项目: mybatis   文件: AnnotatedMapper.java
@Update("update table2 set name = #{name} where id = #{nameId}")
@SelectKey(statement="select name_fred from table2 where id = #{nameId}", keyProperty="generatedName", keyColumn="NAME_FRED", before=false, resultType=String.class)
int updateTable2WithSelectKeyWithKeyMap(Name name);
 
源代码28 项目: mybatis   文件: AnnotatedMapper.java
@Update("update table2 set name = #{name} where id = #{nameId}")
@SelectKey(statement="select name_fred as generatedName from table2 where id = #{nameId}", keyProperty="generatedName", before=false, resultType=Name.class)
int updateTable2WithSelectKeyWithKeyObject(Name name);
 
源代码29 项目: springbootexamples   文件: ProductMapper.java
/**
 * 添加商品
 * @param product
 * @return Long 表示影响的行数
 */
@Insert("insert into product (product_Name, price,product_Brief) values(#{productName}, #{price}, #{productBrief})")
@Options(useGeneratedKeys=true,keyProperty="id")
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = long.class)
public Long insert(Product product);
 
源代码30 项目: uncode-dal-all   文件: CommonMapper.java
/**
 * 新增
 * 所有字段传入 model.params,不能为空
 * @param model
 * @return
 */
@InsertProvider(method = "insert", type = SqlTemplate.class)
@SelectKey(before=false,keyProperty="params.id",resultType=Object.class,statementType=StatementType.STATEMENT,statement="SELECT LAST_INSERT_ID() AS id")
int insert(Table model);