Hbase Phoenix 分页

全部为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作为下一页查询的条件实现分页查询。


  


阅读更多
上一篇dubbo 的monitor监控中心配置
下一篇oracle 自增主键
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭