Oracle-Drools 集成可能吗?

发布于 2024-11-03 19:19:26 字数 158 浏览 4 评论 0原文

我有一些 Drools 文件。 我希望这些 Drools 文件对 Oracle 数据库中的某些记录起作用,然后它们的结果必须更新或插入某些记录。

这可能吗?

I have some Drools files.
I would like these Drools files to act on certain records in the Oracle database and then their outcome must update or insert certain records.

Is this possible?

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

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

发布评论

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

评论(2

静赏你的温柔 2024-11-10 19:19:26

Drools是反动工具。在插入对象时,drools 会创建一个 rete 树,以便在触发规则时触发 THEN 条件。因此,您必须断言工作内存中的对象才能触发规则。

Drools is reactionary tool. While inserting the objects, drools creates a rete tree to fire the THEN condition at the time of firing the rules. Hence, You will have to assert the objects in working memory to fire the rules.

何以笙箫默 2024-11-10 19:19:26

您需要在运行规则之前从数据库加载记录并将其插入到知识库中,或者您可以使用“from”关键字在规则执行期间获取记录。

以下是如何使用“from”和 Hibernate 从数据库获取记录的示例:

# Hibernate session is a global    
global org.hibernate.Session hibernateSession;

rule "hibernate_from"
    when
        game:Game() from hibernateSession.createQuery("select games from Player p where p.age >= :age").setProperties( {"age" : 18 }).list()
    then

        # This is the condition part of the rule, it contains MVEL or in this case Java code
        System.out.println("The game "+game.getName() +"is owned by "+game.getPlayers());
end

更新和插入记录可以在 Drools 规则的条件部分中完成。这部分规则可以用与任何 Java 程序相同的方式编写。

有关“来自”的更多信息,请检查以下内容:

Drools 文档

Jaroslaw Kijanowski 的博客

流口水& jBPM 博客

You need to either load the records from the database and insert them into the knowledge base before you run the rules or you can use the "from" keyword to get the records during rule execution time.

Here is an example how you can get the records from the database using "from" and Hibernate:

# Hibernate session is a global    
global org.hibernate.Session hibernateSession;

rule "hibernate_from"
    when
        game:Game() from hibernateSession.createQuery("select games from Player p where p.age >= :age").setProperties( {"age" : 18 }).list()
    then

        # This is the condition part of the rule, it contains MVEL or in this case Java code
        System.out.println("The game "+game.getName() +"is owned by "+game.getPlayers());
end

Updating and inserting the records can be done in the condition section of the Drools rule. This part of the rule can be written in the same way as any Java program.

For more information about "from" check the following:

Drools documentation

Jaroslaw Kijanowski's blog

Drools & jBPM blog

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