当我们使用id自增操作Mybatis时,需要返回最新插入的id的话,可以进行如下操作
<insert id="insert" parameterType="com.jdd.appim.entity.route.GatewayRouteConfigEntity">
<selectKey resultType="int" order="AFTER" keyProperty="id">
select last_insert_id() as id
</selectKey>
INSERT into gateway_route_config
(
source_url ,
match_mode ,
request_method ,
request_protocol ,
content_type ,
protocol_converts ,
in_handlers ,
out_handlers ,
target_host ,
target_path ,
target_port ,
login_verification_flag ,
route_desc ,
use_original_url ,
status ,
remark ,
extension ,
created_date ,
modified_date ,
last_operator ,
server_group,
cross_domain_access ,
cross_domain_allow_origin ,
aks_access ,
redirect_access ,
target_uri_scheme
)VALUES (
#{sourceUrl},
#{matchCode},
#{requestMethod},
#{requestProtocol},
#{contentType},
#{protocolConverts},
#{inHandlers},
#{outHandlers},
#{targetHost},
#{targetPath},
#{targetPort},
#{loginVerificationFlag},
#{routeDesc},
#{useOriginalUrl},
#{status},
#{remark},
#{extension},
now(),
now(),
#{lastOperator},
#{serverGroup},
#{crossDomainAccess},
#{crossDomainAllowOrigin},
#{aksAccess},
#{redirectAccess},
#{targetUriScheme}
)
</insert>