使用 HTTPRepository 在 Sesame 中添加语句
我正在尝试向 Sesame 存储库添加一些简单的语句,如下所示:
RepositoryConnection connection = repository.connection
connection.autoCommit = false
try {
ValueFactory vf = repository.getValueFactory()
def dummyS = vf.createURI("http://some/uri")
def dummyP = vf.createURI("http://some/uri/hasItem")
uris?.each { uri ->
connection.add(listS, listP, vf.createURI(uri))
}
def stmts = connection.getStatements(listS, null, null, true) ...
当使用 NativeStore 对本地 SailRepository 执行时,效果非常好。但是,当将其连接到托管在不同服务器上的 HTTPRepository 时,“添加”似乎会默默失败。没有抛出异常,但返回的stmts为空。
有人知道可能是什么原因造成的吗?提前致谢!
I'm trying to add some simple statements to a Sesame repository, like so:
RepositoryConnection connection = repository.connection
connection.autoCommit = false
try {
ValueFactory vf = repository.getValueFactory()
def dummyS = vf.createURI("http://some/uri")
def dummyP = vf.createURI("http://some/uri/hasItem")
uris?.each { uri ->
connection.add(listS, listP, vf.createURI(uri))
}
def stmts = connection.getStatements(listS, null, null, true) ...
This works great when executed against a local SailRepository using NativeStore. But when hooking this up to an HTTPRepository hosted on a different server, the 'add' appears to fail silently. No exception is thrown, but the returned stmts is empty.
Anybody have any ideas what could be causing this? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
失败的原因是您使用了 autoCommit=false。在本地设置中,Sesame 的事务隔离会确保即使尚未提交,添加的数据在同一连接上查询时也是可见的。
但是,HTTPRepository 类不支持事务隔离:添加的三元组在您提交之前不可见。因此,要解决此问题,请
在 getStatements() 调用之前添加: 应该没问题。
The reason this fails is that you are using autoCommit=false. In a local setting, Sesame's transaction isolation takes care that even when not yet committed, added data is visible when querying on the same connection.
However, the HTTPRepository class does not support transaction isolation: the added triples are not visible until you have committed. So, to fix, add:
before the getStatements() call and you should be fine.