Catalyzes the 2-epimerization of trans-4-hydroxy-L-proline betaine (tHyp-B) to cis-4-hydroxy-D-proline betaine (cHyp-B). Is involved in a catabolic pathway that degrades tHyp-B to alpha-ketoglutarate. This pathway would permit the utilization of tHyp-B as a carbon and nitrogen source in the absence of osmotic stress, since tHyp-B functions as an osmolyte and is not catabolized when it is needed as osmoprotectant. To a lesser extent, can also catalyze the racemization of L-proline betaine. trans-4-hydroxy-L-proline betaine = cis-4-hydroxy-D-proline betaine L-proline betaine = D-proline betaine Binds 1 Mg(2+) ion per subunit. kcat is 330 sec(-1) with trans-4-hydroxy-L-proline betaine as substrate and 5.3 sec(-1) with L-proline betaine as substrate. Belongs to the mandelate racemase/muconate lactonizing enzyme family.