Surely someone must have had this problem before....
If you try to access a private persistent property from an inner class, it fails silently, making no change to the database.
Code:
public class Robot {
// Persistent property
private int number;
public int getNumber() {return number;}
private void setNumber(int number) {this.number = number;}
public static class PerformanceTuner {
// This does nothing!!
public void tunePerformance(Robot robot) {
robot.setNumber(robot.getNumber()+3);
}
}
}
I'm guessing this is because you can't override private properties and so when you call setNumber it accesses the original object instead of the EnhancerByCLib.
I'm avoiding this problem by making my setters have package level access instead of private, anyone have any better solutions?
[/code]