流口水无限循环
我是流口水的新手。 有人可以告诉为什么尽管没有子句,为什么该规则陷入了无限循环?
declare InvalidPersonalInfoRequest
request: PersonalInfo
msg: String
end
rule "validate first name"
dialect "java"
when
$r: PersonalInfo( firstName == null || firstName == '')
not ( InvalidPersonalInfoRequest( this.request == $r) )
then
String msg = "invalid name";
System.out.println( msg );
insertLogical( new InvalidPersonalInfoRequest($r, msg) );
end
I am new to Drools.
Can someone tell why this rule is running into infinite loop despite not clause ?
declare InvalidPersonalInfoRequest
request: PersonalInfo
msg: String
end
rule "validate first name"
dialect "java"
when
$r: PersonalInfo( firstName == null || firstName == '')
not ( InvalidPersonalInfoRequest( this.request == $r) )
then
String msg = "invalid name";
System.out.println( msg );
insertLogical( new InvalidPersonalInfoRequest($r, msg) );
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您正在使用
insertlogical
而不是insert
。From the Drools documentation:
当您使用
插入术
时,当触发条件停止到真时,将插入的对象从内存中删除。由于您的插入立即否定了条件,因此立即将其从内存中删除。交换到
插入
以按照您的预期工作。It's because you're using
insertLogical
instead ofinsert
.From the Drools documentation:
When you use
insertLogical
, the inserted object is removed from memory when the triggering condition stops being true. Since your insertion immediately negates the condition, it's immediately removed from memory.Swap over to
insert
to work as you expect.