Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
247dd49a
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
247dd49a
编写于
5月 16, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Value binder model
Former-commit-id:
a7e2deb9
上级
f9365988
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
11 deletion
+55
-11
plugins/org.jkiss.dbeaver.data.gis/src/org/jkiss/dbeaver/data/gis/handlers/GISGeometryValueHandler.java
...ss/dbeaver/data/gis/handlers/GISGeometryValueHandler.java
+3
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDValueBinder.java
...odel/src/org/jkiss/dbeaver/model/data/DBDValueBinder.java
+31
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/ExecuteBatchImpl.java
...c/org/jkiss/dbeaver/model/impl/data/ExecuteBatchImpl.java
+2
-2
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCTable.java
...c/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCTable.java
+19
-6
未找到文件。
plugins/org.jkiss.dbeaver.data.gis/src/org/jkiss/dbeaver/data/gis/handlers/GISGeometryValueHandler.java
浏览文件 @
247dd49a
...
...
@@ -83,7 +83,7 @@ public class GISGeometryValueHandler extends JDBCAbstractValueHandler {
}
}
protected
void
bindGeometryParameter
(
JDBCSession
session
,
JDBCPreparedStatement
statement
,
int
paramIndex
,
Geometry
value
)
throws
SQLException
,
DBCException
{
protected
void
bindGeometryParameter
(
@NotNull
JDBCSession
session
,
@NotNull
JDBCPreparedStatement
statement
,
int
paramIndex
,
@NotNull
Geometry
value
)
throws
SQLException
,
DBCException
{
bindBytes
(
statement
,
paramIndex
,
convertGeometryToBinaryFormat
(
session
,
value
));
}
...
...
@@ -141,11 +141,11 @@ public class GISGeometryValueHandler extends JDBCAbstractValueHandler {
return
super
.
getValueDisplayString
(
column
,
value
,
format
);
}
protected
byte
[]
fetchBytes
(
JDBCResultSet
resultSet
,
int
index
)
throws
SQLException
{
protected
byte
[]
fetchBytes
(
@NotNull
JDBCResultSet
resultSet
,
int
index
)
throws
SQLException
{
return
resultSet
.
getBytes
(
index
);
}
protected
void
bindBytes
(
JDBCPreparedStatement
dbStat
,
int
index
,
byte
[]
bytes
)
throws
SQLException
{
protected
void
bindBytes
(
@NotNull
JDBCPreparedStatement
dbStat
,
int
index
,
@NotNull
byte
[]
bytes
)
throws
SQLException
{
dbStat
.
setBytes
(
index
,
bytes
);
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDValueBinder.java
0 → 100644
浏览文件 @
247dd49a
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.model.data
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
/**
* Provides possibility to override default SQL query binding
*/
public
interface
DBDValueBinder
extends
DBDValueHandler
{
String
makeQueryBind
(
DBSAttributeBase
attribute
)
throws
DBCException
;
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/ExecuteBatchImpl.java
浏览文件 @
247dd49a
...
...
@@ -148,7 +148,7 @@ public abstract class ExecuteBatchImpl implements DBSDataManipulator.ExecuteBatc
}
}
if
(
statement
==
null
||
!
reuse
)
{
statement
=
prepareStatement
(
session
,
rowValues
);
statement
=
prepareStatement
(
session
,
handlers
,
rowValues
);
statistics
.
setQueryText
(
statement
.
getQueryString
());
statistics
.
addStatementsCount
();
}
...
...
@@ -324,7 +324,7 @@ public abstract class ExecuteBatchImpl implements DBSDataManipulator.ExecuteBatc
}
@NotNull
protected
abstract
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
Object
[]
attributeValues
)
throws
DBCException
;
protected
abstract
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
DBDValueHandler
[]
handlers
,
Object
[]
attributeValues
)
throws
DBCException
;
protected
abstract
void
bindStatement
(
@NotNull
DBDValueHandler
[]
handlers
,
@NotNull
DBCStatement
statement
,
Object
[]
attributeValues
)
throws
DBCException
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCTable.java
浏览文件 @
247dd49a
...
...
@@ -325,7 +325,7 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte
@NotNull
@Override
protected
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
Object
[]
attributeValues
)
throws
DBCException
{
protected
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
DBDValueHandler
[]
handlers
,
Object
[]
attributeValues
)
throws
DBCException
{
// Make query
StringBuilder
query
=
new
StringBuilder
(
200
);
query
...
...
@@ -358,7 +358,13 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte
}
if
(
hasKey
)
query
.
append
(
","
);
//$NON-NLS-1$
hasKey
=
true
;
query
.
append
(
"?"
);
//$NON-NLS-1$
DBDValueHandler
valueHandler
=
handlers
[
i
];
if
(
valueHandler
instanceof
DBDValueBinder
)
{
query
.
append
(((
DBDValueBinder
)
valueHandler
)
.
makeQueryBind
(
attribute
));
}
else
{
query
.
append
(
"?"
);
//$NON-NLS-1$
}
}
query
.
append
(
")"
);
//$NON-NLS-1$
...
...
@@ -408,7 +414,7 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte
return
new
ExecuteBatchImpl
(
attributes
,
keysReceiver
,
false
)
{
@NotNull
@Override
protected
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
Object
[]
attributeValues
)
throws
DBCException
{
protected
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
DBDValueHandler
[]
handlers
,
Object
[]
attributeValues
)
throws
DBCException
{
String
tableAlias
=
null
;
SQLDialect
dialect
=
((
SQLDataSource
)
session
.
getDataSource
()).
getSQLDialect
();
if
(
dialect
.
supportsAliasInUpdate
())
{
...
...
@@ -423,13 +429,20 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte
query
.
append
(
"\nSET "
);
//$NON-NLS-1$ //$NON-NLS-2$
boolean
hasKey
=
false
;
for
(
DBSAttributeBase
attribute
:
updateAttributes
)
{
for
(
int
i
=
0
;
i
<
updateAttributes
.
length
;
i
++)
{
DBSAttributeBase
attribute
=
updateAttributes
[
i
];
if
(
hasKey
)
query
.
append
(
","
);
//$NON-NLS-1$
hasKey
=
true
;
if
(
tableAlias
!=
null
)
{
query
.
append
(
tableAlias
).
append
(
dialect
.
getStructSeparator
());
}
query
.
append
(
getAttributeName
(
attribute
)).
append
(
"=?"
);
//$NON-NLS-1$
query
.
append
(
getAttributeName
(
attribute
)).
append
(
"="
);
//$NON-NLS-1$
DBDValueHandler
valueHandler
=
handlers
[
i
];
if
(
valueHandler
instanceof
DBDValueBinder
)
{
query
.
append
(((
DBDValueBinder
)
valueHandler
)
.
makeQueryBind
(
attribute
));
}
else
{
query
.
append
(
"?"
);
//$NON-NLS-1$
}
}
if
(
keyAttributes
.
length
>
0
)
{
query
.
append
(
"\nWHERE "
);
//$NON-NLS-1$
...
...
@@ -477,7 +490,7 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte
return
new
ExecuteBatchImpl
(
keyAttributes
,
null
,
false
)
{
@NotNull
@Override
protected
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
Object
[]
attributeValues
)
throws
DBCException
{
protected
DBCStatement
prepareStatement
(
@NotNull
DBCSession
session
,
DBDValueHandler
[]
handlers
,
Object
[]
attributeValues
)
throws
DBCException
{
String
tableAlias
=
null
;
SQLDialect
dialect
=
((
SQLDataSource
)
session
.
getDataSource
()).
getSQLDialect
();
if
(
dialect
.
supportsAliasInUpdate
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录