mybatis分页和主键生成
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis分页和主键生成相关的知识,希望对你有一定的参考价值。
oracle 使用 mybatis的时候,主键自动生成:
<insert id="createBigOrder" parameterType="BigOrder" useGeneratedKeys="true" keyProperty="id">
<selectKey resultType="int" order="BEFORE" keyProperty="id">
SELECT SEQ_BIG_ORDER_ID.NEXTVAL FROM dual
</selectKey>
insert into
BIG_ORDER
( ID,
BIGORDER_CODE,
MEMBER_ID,
SHOPGUIDE_ID,
CHANNEL_ID,
PAY_PRICE,
PAY_WAY,
GOODS_TOTAL_COUNT,
GSC_PICMIAN_ID,
PIC_URL,
PROVINCE,
CITY,
DETAIL_ADDRESS,
CONSIGNEE,
CONTACT_TEL,
BIND_SKU,
BIND_COUNT,
BIND_REASON,
BRAND_CODE,
REAL_SELL_PRICE,
CREATE_TIME,
UPDATE_TIME,
AREA,
EMAIL,
SALE_SHOP,
ORIGINAL_TOTAL_PRICE,
CRM_ID,
rule_Id,
promotion_type_name,
P_TYPE_CODE,
P_PRICE_RULE,
P_MARKUP_PRICE,
P_QUANTITY_RULE,
P_START_TIME,
P_END_TIME,
P_DESCRIPTION)
values
(
#{id},
#{bigorderCode},
#{memberId,jdbcType=BIGINT},
#{shopguideId,jdbcType=VARCHAR},
#{channelId},
#{payPrice},
#{payWay,jdbcType=VARCHAR},
#{goodsTotalCount},
#{gscPicmianId,jdbcType=BIGINT},
#{picUrl},
#{province},
#{city},
#{detailAddress},
#{consignee},
#{contactTel},
#{bindSku,jdbcType=VARCHAR},
#{bindCount,jdbcType=BIGINT},
#{bindReason,jdbcType=VARCHAR},
#{brandCode},
#{realSellPrice},
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},
#{area},
#{email,jdbcType=VARCHAR},
#{saleShop,jdbcType=VARCHAR},
#{originalTotalPrice},
#{crmId,jdbcType=VARCHAR},
#{ruleId,jdbcType=BIGINT},
#{promotionTypeName,jdbcType=VARCHAR},
#{pTypeCode,jdbcType=VARCHAR},
#{pPriceRule,jdbcType=DOUBLE},
#{pMarkupPrice,jdbcType=DOUBLE},
#{pQuantityRule,jdbcType=BIGINT},
#{pStartTime,jdbcType=TIMESTAMP},
#{pEndTime,jdbcType=TIMESTAMP},
#{pDescription,jdbcType=VARCHAR})
</insert>
使用mybatis分页配置:
<configuration>
<typeAliases>
<typeAlias type="com.zyhao.demo.rest.entities.Demo" alias="Demo"/>
<typeAlias type="org.zywx.lzsz.entity.order.BigOrder" alias="BigOrder"/>
<typeAlias type="org.zywx.lzsz.entity.cart.ShoppingCart" alias="ShoppingCart" />
</typeAliases>
<!-- 添加mybatis分页插件 :指定oracle方言-->
<plugins>
<plugin interceptor="com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor">
<property name="dialectClass" value="com.github.miemiedev.mybatis.paginator.dialect.OracleDialect"/>
</plugin>
</plugins>
<mappers>
<mapper resource="mappers/demo.xml" />
<mapper resource="mappers/order/bigorder.xml" />
<mapper resource="mappers/cart/shoppingCart.xml"/>
</mappers>
</configuration>
以上是关于mybatis分页和主键生成的主要内容,如果未能解决你的问题,请参考以下文章