The axis locks are a UI feature that only provides a simple lock in the 3dview and they are easy to work around. To completely limit transformations you should use constraints. Constraints are the last thing applied to an object, they will limit the transformation values even if you have keyframes on the value that are outside the constraint settings.
For your example the Limit Rotation constraint will prevent rotation on a specified axes, you can also limit the rotation to a range so that you could only rotate the joint 45 degrees.
A limit with min and max at 0.0 will prevent any rotation, you may also set both at a certain angle.