public class SqlUtil extends Object
Constructor and Description |
---|
SqlUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
blobToStr(Blob blob,
Charset charset)
Blob字段值转字符串
|
static Condition[] |
buildConditions(Entity entity)
通过实体对象构建条件对象
|
static String |
buildEqualsWhere(Entity entity,
List<Object> paramValues)
构件相等条件的where语句
如果没有条件语句,泽返回空串,表示没有条件 |
static String |
buildLikeValue(String value,
Condition.LikeType likeType,
boolean withLikeKeyword)
创建LIKE语句中的值,创建的结果为:
1、LikeType.StartWith: '%value'
2、LikeType.EndWith: 'value%'
3、LikeType.Contains: '%value%'
如果withLikeKeyword为true,则结果为:
1、LikeType.StartWith: LIKE '%value'
2、LikeType.EndWith: LIKE 'value%'
3、LikeType.Contains: LIKE '%value%'
|
static String |
clobToStr(Clob clob)
Clob字段值转字符串
|
static Blob |
createBlob(Connection conn,
byte[] data)
创建Blob对象
|
static Blob |
createBlob(Connection conn,
InputStream dataStream,
boolean closeAfterUse)
创建Blob对象
|
static String |
formatSql(String sql)
格式化SQL
|
static String |
rowIdToString(RowId rowId)
将RowId转为字符串
|
static Date |
toSqlDate(Date date)
转换为
Date |
static Timestamp |
toSqlTimestamp(Date date)
转换为
Timestamp |
public static String buildEqualsWhere(Entity entity, List<Object> paramValues)
entity
- 条件实体paramValues
- 条件值得存放Listpublic static Condition[] buildConditions(Entity entity)
entity
- 实体对象public static String buildLikeValue(String value, Condition.LikeType likeType, boolean withLikeKeyword)
1、LikeType.StartWith: '%value' 2、LikeType.EndWith: 'value%' 3、LikeType.Contains: '%value%'
如果withLikeKeyword为true,则结果为:
1、LikeType.StartWith: LIKE '%value' 2、LikeType.EndWith: LIKE 'value%' 3、LikeType.Contains: LIKE '%value%'
value
- 被查找值likeType
- LIKE值类型 Condition.LikeType
withLikeKeyword
- 是否包含LIKE关键字public static String rowIdToString(RowId rowId)
rowId
- RowIdpublic static String clobToStr(Clob clob)
clob
- Clob
public static String blobToStr(Blob blob, Charset charset)
blob
- Blob
charset
- 编码public static Blob createBlob(Connection conn, InputStream dataStream, boolean closeAfterUse)
conn
- Connection
dataStream
- 数据流,使用完毕后关闭closeAfterUse
- 使用完毕是否关闭流Blob
public static Blob createBlob(Connection conn, byte[] data)
conn
- Connection
data
- 数据Blob
Copyright © 2024. All rights reserved.