有没有办法将 Hibernate Session 读取为 RDF 三元组?

发布于 2024-07-29 22:35:08 字数 240 浏览 7 评论 0原文

我需要根据 WHERE 子句的相关数据位于链接开放数据云中的条件,查询本地 Hibernate 托管数据存储中的持久对象。

有没有办法将 Hibernate Session 读取为 RDF? 如果是这样,我至少可以使用组合数据集来决定从 Hibernate 检索哪些对象。

最好的解决方案是将 Hibernate 会话暴露在耶拿内部,因为我很熟悉它。 此外,我还需要 RDFS 推理和 SPARQL 的支持以进行检索。

I need to query my local Hibernate managed datastore for persisted objects based on criteria where the relevant data for the WHERE clause is in the Linked Open Data cloud.

Is there a way to read a Hibernate Session as RDF? If so, I can at least use the combined Dataset to decide what objects to retrieve from Hibernate.

Preferably the solution would expose the Hibernate Session as inside Jena as I'm familiar with it. In addition I'll need support for RDFS inferencing and SPARQL for retrieval.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

×眷恋的温暖 2024-08-05 22:35:08

由于您将使用 Jena(和 ARQ)来执行 SPARQL 查询,因此您可以使用自定义 FileManager 来解析 Hibernate 对象/图形(假设您希望每个对象都由图形表示)。

Jena 有一个关于使用 FileManager简短的 HOWTO定位模型,以及 ARQ RDF 数据集教程(请参阅“描述数据集”部分)可能会给出一些关于如何将图形 URI(以及这些图形的内容作为 RDF 数据集)到现有 Hibernate 管理的数据进行更定制的映射的提示。

另一个选择可能是创建一个映射到现有 Hibernate 架构的自定义 SDB 布局 。 我不知道SDB在这方面的灵活性如何。

Since you will be using Jena (and ARQ) to execute your SPARQL query, you could use a custom FileManager to resolve the Hibernate objects/graphs (assuming you want each object to be represented by a graph).

Jena has a short HOWTO on using a FileManager to locate models, and the ARQ RDF dataset tutorial (see the "Describing Datasets" section) may give some hints as to how to do a more customized mapping of graph URIs (and the contents of those graphs as RDF datasets) to your existing Hibernate-managed data.

Another option might be creating a custom SDB layout which maps to your existing Hibernate schema. I don't know how flexible SDB is in this regard.

城歌 2024-08-05 22:35:08

以下是我发布问题后发现的内容:

没有现有的工具可以专门将 Hibernate 会话三重化。 要自己实现一个,我需要实现 Graph< /a> 也许使用 GraphBase作为基础,或者StageGenerator。 因此问题的答案是“没有”,所以我接着考虑如何实现。

我需要决定是否将会话中已有的对象(即已被某些早期查询访问过)三倍化,依赖于访问数据库或两者都进行。 如果要访问数据库,我还需要决定是加载整个对象,然后将其附加到会话,还是使用投影来节省将额外数据引入堆的时间,而代价是额外的往返。

使用 Graph 显然对于支持推理至关重要,尽管它比使用 ARQ 慢 StageGenerator 因为它可以查询一组三元组模式,但这使得必须始终使用 SPARQL,这似乎有点不灵活。

到目前为止,最佳解决方案似乎是:

  • 实施一个(可能是只读的)
    图表 - 说“HibernateGraph”
  • 让 HibernateGraph 检查
    Hibernate PersistenceContext 对象
    并在 an 的头部返回三元组
    自定义迭代器。
  • 当迭代器过期时加载页面
    使用来自数据库的数据
    标准接口。
  • 对于具有已知谓词的查询
    URI 将 URI 映射到列并使用
    紧密投影,否则加载
    整个对象并迭代
    getter,将 getter 名称映射到
    URI。
  • 在其他情况下,使用简单的方案进行映射,例如 http://root/url/instances/EntityName/id 为每个主题等
  • 创建一个辅助对象以允许
    使用自定义执行的 SPARQL
    舞台生成器。
  • StageGenerator 应该包装
    内置于 StageGenerator 中。
  • 在自定义阶段生成器传递
    对除 a 之外的图的查询
    HibernateGraph 的链向上
    内置于 StageGenerator 中。
  • 还可以跳过任何一组三重模式
    没有优化的
    解决方案,例如任何一组模式。
  • 优化查询可以在哪里
    已实现,运行适当的
    标准函数并映射
    结果逐个细胞变为三倍
    前。

还有另一个名为 OpExecutor 的 SPI 可能有助于推送 FILTER解析到数据库中,从而进一步提高性能。

目前我已将其作为一个业余项目,我很可能将其作为 LGPL 软件发布。

Here's what I've found since posting the question:

There is no existing tool to triplify the Hibernate Session specifically. To implement one myself I need to implement Graph perhaps using GraphBase as a basis, or StageGenerator. The answer to the question is therefore "there isn't one", so I went on to consider how to implement it.

I need to decide whether to triplify objects already in the session (i.e. already accessed by some earlier query), rely on accessing the database or do both. If going to the database I also need to decide whether to load whole objects which will then be attached to the session or use projection to save bringing extra data into the heap at the expense of additional round-trips.

Using Graph is apparently essential for supporting inferencing, though its slower than using ARQs StageGenerator since that can query a set of triple patterns, however this makes it essential to always use SPARQL which seems a bit inflexible.

So far, the optimum solution appears to be:

  • Implement a (probably read-only)
    Graph - say "HibernateGraph"
  • Have HibernateGraph inspect the
    Hibernate PersistenceContext object
    and return triples at the head of an
    custom iterator.
  • When the iterator expires load pages
    of data from the database using the
    Criteria interfaces.
  • For queries with a known predicate
    URI map the URI to a column and use a
    tight projection, otherwise load the
    whole object and iterate over
    getters, mapping the getter name to a
    URI.
  • In other cases map using a simple scheme e.g. http://root/url/instances/EntityName/id for each subject etc
  • Create a helper object to allow
    SPARQL to be performed with a custom
    StageGenerator.
  • The StageGenerator should wrap the
    built in StageGenerator.
  • In the custom stage generator pass
    queries on graphs other than a
    HibernateGraph up the chain to the
    built in StageGenerator.
  • Also skip any set of triple patterns
    for which there is no optimised
    solution e.g any set of one pattern.
  • Where an optimized query can be
    achieved, run the appropriate
    Criteria functions and map the
    results cell-by-cell to triples as
    before.

There is another SPI called OpExecutor which may help to push FILTER resolution into the database, therefore improving performance further.

At the moment I've taken this on as a side project, which I may well release as LGPL software.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文