A hydraulic cylinder comprising: an elongate body defining an internal cavity that extends along a longitudinal axis of the elongate body; a pair of end caps (26, 28) at opposite ends of the elongate body; a piston and rod assembly (18, 19) at least partially in the internal cavity, the piston and rod assembly (18, 19) being movable in a direction of the longitudinal axis; a position sensor and a sensor rod in the internal cavity, the sensor rod extending along the longitudinal axis; and a sensor retainer assembly (50, 150, 250) in the internal cavity, the sensor retainer assembly (50, 150, 250) being coaxial with the sensor rod and adapted to retain the sensor rod at the longitudinal axis, the sensor retainer assembly (50, 150, 250) including: an annular body (60, 160, 260) defining a bore (61, 161, 261) extending from opposite ends of the annular body (60, 160, 260), the bore (61, 161, 261) being adapted to receive the sensor rod such that the sensor rod extends from the opposite ends of the annular body (60, 160, 260), a magnet ring (70, 170, 270) disposed in the bore (61, 161, 261) at an inner wall (64, 164, 264) of the annular body (60, 160, 260), the magnet ring (70, 170, 270) being radially outward of the sensor rod, and one or more magnets (80, 180, 280) fixedly disposed between the annular body (60, 160, 260) and the magnet ring (70, 170, 270) in a radial direction of the annular body (60, 160, 260), the one or more magnets (80, 180, 280) being radially outward of the sensor rod, wherein each of the one or more magnets (80, 180, 280) is fixedly molded between the annular body (60, 160, 260) and the magnet ring (70, 170, 270). an elongate body defining an internal cavity that extends along a longitudinal axis of the elongate body; a pair of end caps (26, 28) at opposite ends of the elongate body; a piston and rod assembly (18, 19) at least partially in the internal cavity, the piston and rod assembly (18, 19) being movable in a direction of the longitudinal axis; a position sensor and a sensor rod in the internal cavity, the sensor rod extending along the longitudinal axis; and a sensor retainer assembly (50, 150, 250) in the internal cavity, the sensor retainer assembly (50, 150, 250) being coaxial with the sensor rod and adapted to retain the sensor rod at the longitudinal axis, the sensor retainer assembly (50, 150, 250) including: an annular body (60, 160, 260) defining a bore (61, 161, 261) extending from opposite ends of the annular body (60, 160, 260), the bore (61, 161, 261) being adapted to receive the sensor rod such that the sensor rod extends from the opposite ends of the annular body (60, 160, 260), a magnet ring (70, 170, 270) disposed in the bore (61, 161, 261) at an inner wall (64, 164, 264) of the annular body (60, 160, 260), the magnet ring (70, 170, 270) being radially outward of the sensor rod, and one or more magnets (80, 180, 280) fixedly disposed between the annular body (60, 160, 260) and the magnet ring (70, 170, 270) in a radial direction of the annular body (60, 160, 260), the one or more magnets (80, 180, 280) being radially outward of the sensor rod, wherein each of the one or more magnets (80, 180, 280) is fixedly molded between the annular body (60, 160, 260) and the magnet ring (70, 170, 270). an annular body (60, 160, 260) defining a bore (61, 161, 261) extending from opposite ends of the annular body (60, 160, 260), the bore (61, 161, 261) being adapted to receive the sensor rod such that the sensor rod extends from the opposite ends of the annular body (60, 160, 260), a magnet ring (70, 170, 270) disposed in the bore (61, 161, 261) at an inner wall (64, 164, 264) of the annular body (60, 160, 260), the magnet ring (70, 170, 270) being radially outward of the sensor rod, and one or more magnets (80, 180, 280) fixedly disposed between the annular body (60, 160, 260) and the magnet ring (70, 170, 270) in a radial direction of the annular body (60, 160, 260), the one or more magnets (80, 180, 280) being radially outward of the sensor rod, wherein each of the one or more magnets (80, 180, 280) is fixedly molded between the annular body (60, 160, 260) and the magnet ring (70, 170, 270).