关闭

Hbase Phoenix 分页

703人阅读 评论(0) 收藏 举报

全部为mybatis.xml 内容

1.创建表

	<insert id="createTable">
		create table if not exists "FVE_VoucherStorage"
		(
		"fid" varchar not null primary key,
		"cf"."fvoucherCode" varchar,
		"cf"."fdate" varchar,
		"cf"."frgnId" varchar,
		"cf"."fyear" varchar,
		"cf"."fvoucherTypeId" varchar,
		"cf"."fisValid" varchar,
		"cf"."fvoucherVersion" varchar,
		"cf"."fcreateTime" varchar,
		"cf"."foriginContent" varchar,
		"cf"."fcontent" varchar,
		"cf"."fflagId" varchar,
		"cf"."foriginCode" varchar,
		"cf"."fagenName" varchar,
		"cf"."frowId" bigint
		)
	</insert>
*注意frowId字段,用于存储自增序列

2.创建实体类

    这个没有什么说的,普通的实体类而已

3.建立sequence(自增序列)

	<insert id="sequence">CREATE SEQUENCE SEQ</insert>
4.插入数据

<insert id="insertVoucher" parameterType="com.domain.VoucherStorage">
		upsert into
		"FVE_VoucherStorage"("fid","fvoucherCode","fdate","frgnId","fyear","fvoucherTypeId","fisValid","fvoucherVersion","fcreateTime",
		"foriginContent","fcontent","fflagId","foriginCode","frowId")values(
		#{fid},#{fvoucherCode},#{fdate},#{frgnId},#{fyear},#{fvoucherTypeId},#{fisValid},#{fvoucherVersion},#{fcreateTime},
		#{foriginContent},#{fcontent},#{fflagId},#{foriginCode},NEXT VALUE FOR
		SEQ)
	</insert>
*注意NEXT VALUE FOR SEQ 这句话,将自增序列添加给frowId
5查询语句

<select id="selectByCondition" parameterType="map"
		resultType="com.domain.VoucherStorage">
		select * from
		"FVE_VoucherStorage"
		where 1=1 
		<if test="fisValid!=null and fisValid!=''">
		<![CDATA[
		and "fisValid" = #{fisValid}
			]]>
		</if>
		<if test="fvoucherTypeId!=null and fvoucherTypeId!=''">
		<![CDATA[
        and  "fvoucherTypeId" =#{fvoucherTypeId} 
		]]>
		</if>
		<if test="beginDate!=null and beginDate!=''">
		<![CDATA[
		 and "fdate" >= #{beginDate}
		]]>
		</if>
		<if test="endDate!=null and endDate!=''">
		<![CDATA[
		 and "fdate" <= #{endDate}
		]]>
		</if>
		<if test="frowId!=null and frowId!=''">
		<![CDATA[
		 and "frowId">=#{frowId}
		]]>
		</if>
		ORDER BY
		"frowId" ASC LIMIT #{pageSize}
		
	</select>

查询时,将pageSize设置为页数+1,多余出的一条记录中的frowId作为下一页查询的条件实现分页查询。


  


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:24109次
    • 积分:521
    • 等级:
    • 排名:千里之外
    • 原创:21篇
    • 转载:10篇
    • 译文:7篇
    • 评论:5条
    最新评论