Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-703

Allow overriding annotated methods in subclasses, such as @PlanningId, @PlanningVariable, ...

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Major Major
    • Future
    • 7.0.0.Beta3
    • optaplanner-core
    • NEW
    • NEW

      Given

      public abstract class AbstractPersistable {
      
          @PlanningId
          public Long getId() {
              return id;
          }
      
      public class CloudProcess extends AbstractPersistable {
      
          @Override
          @PlanningId()
          public Long getId() {
              return super.getId() + 1000L;
          }
      

      it currently throws:

      java.lang.IllegalStateException: The class (class org.optaplanner.examples.cloudbalancing.domain.CloudProcess) has 2 members ([public java.lang.Long org.optaplanner.examples.cloudbalancing.domain.CloudProcess.getId(), public java.lang.Long org.optaplanner.examples.common.domain.AbstractPersistable.getId()]) with a PlanningId annotation.
      
      	at org.optaplanner.core.impl.domain.locator.LocationStrategyResolver.findPlanningIdMemberAccessor(LocationStrategyResolver.java:109)
      	at org.optaplanner.core.impl.domain.locator.LocationStrategyResolver.lambda$determineLocationStrategy$0(LocationStrategyResolver.java:74)
      	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1688)
      	at org.optaplanner.core.impl.domain.locator.LocationStrategyResolver.determineLocationStrategy(LocationStrategyResolver.java:71)
      	at org.optaplanner.core.impl.domain.locator.Locator.addWorkingObject(Locator.java:51)
      	at org.optaplanner.core.impl.domain.locator.Locator.resetWorkingObjects(Locator.java:46)
      	at org.optaplanner.core.impl.score.director.AbstractScoreDirector.setWorkingSolution(AbstractScoreDirector.java:158)
      	at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.setWorkingSolution(DroolsScoreDirector.java:61)
      	at org.optaplanner.core.impl.solver.scope.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:225)
      	at org.optaplanner.core.impl.solver.AbstractSolver.solvingStarted(AbstractSolver.java:75)
      	at org.optaplanner.core.impl.solver.DefaultSolver.solvingStarted(DefaultSolver.java:178)
      	at org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:159)
      	at org.optaplanner.examples.common.app.AbstractPhaseTest.runPhase(AbstractPhaseTest.java:79)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.lang.Thread.run(Thread.java:745)
      

      We might want to support overriding annotations.

              Unassigned Unassigned
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: