[
https://issues.jboss.org/browse/JBRULES-3054?page=com.atlassian.jira.plug...
]
Tomáš Schlosser updated JBRULES-3054:
-------------------------------------
Description:
This code:
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
int sessionID = ksession.getId();
Object expected = new Person(42, "person");
ksession.insert(expected);
ksession.dispose();
System.out.println("Created knowledge session");
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionID, kbase,
null, env);
Collection<Object> objects = ksession.getObjects();
System.out.println("Object count: " + objects.size());
Object actual = objects.iterator().next();
System.out.println("Object: " + actual);
System.out.println("actual.equals(expected): " +
actual.equals(expected));
System.out.println("expected.equals(actual): " +
expected.equals(actual));
System.out.println("objects.contains(expected): " +
objects.contains(expected));
results in:
Created knowledge session
Object count: 1
Object: org.sample.Person@49
actual.equals(expected): true
expected.equals(actual): true
objects.contains(expected): false
Class Person has overriden equals() method to the compare Person's ID
was:
This code:
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
int sessionID = ksession.getId();
Object expected = new Person(42, "person");
ksession.insert(expected);
ksession.dispose();
System.out.println("Created knowledge session");
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionID, kbase,
null, env);
Collection<Object> objects = ksession.getObjects();
System.out.println("Object count: " + objects.size());
Object actual = objects.iterator().next();
System.out.println("Object: " + actual);
System.out.println("actual.equals(expected): " +
actual.equals(expected));
System.out.println("expected.equals(actual): " +
expected.equals(actual));
System.out.println("objects.contains(expected): " +
objects.contains(expected));
results in:
Created knowledge session
Object count: 1
Object: org.sample.Person@49
actual.equals(expected): true
expected.equals(actual): true
objects.contains(expected): false
Contains not working on collection of StatefulKnowledgeSession
objects
----------------------------------------------------------------------
Key: JBRULES-3054
URL:
https://issues.jboss.org/browse/JBRULES-3054
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 5.2.0.M2
Reporter: Tomáš Schlosser
Assignee: Mark Proctor
This code:
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
int sessionID = ksession.getId();
Object expected = new Person(42, "person");
ksession.insert(expected);
ksession.dispose();
System.out.println("Created knowledge session");
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionID, kbase,
null, env);
Collection<Object> objects = ksession.getObjects();
System.out.println("Object count: " + objects.size());
Object actual = objects.iterator().next();
System.out.println("Object: " + actual);
System.out.println("actual.equals(expected): " +
actual.equals(expected));
System.out.println("expected.equals(actual): " +
expected.equals(actual));
System.out.println("objects.contains(expected): " +
objects.contains(expected));
results in:
Created knowledge session
Object count: 1
Object: org.sample.Person@49
actual.equals(expected): true
expected.equals(actual): true
objects.contains(expected): false
Class Person has overriden equals() method to the compare Person's ID
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira