Hi,
I am learning OptaPlanner, but here is one problem confused me. I modified the example of TimeTable from OptaPlanner website, and added @PlanningEntity to Room.java, also added a field private Integer lessonCount with @ShadowVariable annoated. But it throws exception and says: The entityClass (class com.example.optatest.timeTabling.entity.Room) has a @ShadowVariable annotated property (lessonCount) with a sourceEntityClass (class com.example.optatest.timeTabling.entity.Lesson) which is not a valid planning entity.
Below are codes.
1, Lesson.java
@PlanningEntity
public class Lesson {
@PlanningId
private Long id;
private String subject;
private String teacher;
private String studentGroup;
@PlanningVariable
private Timeslot timeslot;
@PlanningVariable
private Room room;
// construction
// getter and setter
}
2, Room.java
@PlanningEntity
public class Room {
@PlanningId
private Long id;
private String name;
@ShadowVariable(variableListenerClass = LessonCountUpdatingVariableListener.class, sourceEntityClass = Lesson.class, sourceVariableName = "room")
private Integer lessonCount = 0;
// constructions
// getter and setter
}
Please support: what should i do that i can make the field lessonCount be changed following the field room of Lesson.java.
thanks.