Hi, all: </br>
I'm a newbie to Drools.</br>

I'm trying to restore stateful knowledge session using JPAKnowledgeService after restarting server. In my rules I use Drools Fusion's Sliding Length Window to processing events. Below is a sample: 
<p>package com.sample</br> 
import com.sample.Event;</br>
import java.util.List;<br/>
declare Event @role(event) end<br/><br/>
rule "test"<br/>
when<br/> 
$list : List() from collect(Event() over window: length(2))<br/>
then<br/>
System.out.println("list size:" + $list.size());<br/>
end</p> 
And I have done what should be done according to the manual reference. When I running my test case below:<p>
@Test<br/>
public void test_persistedsession() {<br/>
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();<br/>
loadDRL(kbase);<br/>
Environment env = KnowledgeBaseFactory.newEnvironment();<br/>
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory( "org.drools.persistence.jpa"));<br/>
env.set( EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());<br/><br/> 
//create a persisted statefulknowledgesession<br/>
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);<br/><br/> 
ksession.insert(new Event());<br/> 
ksession.fireAllRules();<br/><br/> 
ksession.insert(new Event());<br/>
ksession.fireAllRules();<br/><br/>
//reload the persisted session<br/>
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(ksession.getId(), kbase, null, env); <br/><br/>
ksession.insert(new Event());<br/> ksession.fireAllRules();<br/><br/>
 ksession.insert(new Event());<br/> 
ksession.fireAllRules();<br/>
}<br/></p>
Then I found that the result is:<p>
Hibernate: insert into SessionInfo (id, lastModificationDate, rulesByteArray, startDate, OPTLOCK) values (null, ?, ?, ?, ?) <br/>
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=? <br/>
list size:1<br/>
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=? <br/>
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=?<br/>
list size:2</br>
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=? <br/>
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=?<br/>
list size:3<br/>
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=? Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=?<br/>
list size:4<br/>
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=? and OPTLOCK=? </p>
As I have declared that the length of window is 2, how can the size of list increase to 3, 4 and more? </br>
I am using the 5.2.0 final. May be I have missed something, please help me. </br>
Any help will be appreciated. 

        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://drools.46999.n3.nabble.com/persisted-StatefulKnowledgeSession-failed-to-maintain-the-length-of-Sliding-window-tp4019696p4019697.html">Re: persisted StatefulKnowledgeSession failed to maintain the length of Sliding window?</a><br/>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools: User forum mailing list archive</a> at Nabble.com.<br/>