2. Given the quadratic function $y=(x-a)(x-b)-\frac{1}{2}$ $(a<b)$, and $x_{1} 、 x_{2}\left(x_{1}<x_{2}\right)$ are the two roots of the equation
$$
(x-a)(x-b)-\frac{1}{2}=0
$$

The size relationship of the real numbers $a 、 b 、 x_{1} 、 x_{2}$ is ( ).
(A) $a<x_{1}<b<x_{2}$
(B) $a<x_{1}<x_{2}<b$
(C) $x_{1}<a<x_{2}<b$
(D) $x_{1}<a<b<x_{2}$
2. D.

Let $y^{\prime}=(x-a)(x-b)$, its graph is the parabola (1) in Figure 4, and its intersections with the $x$-axis have the abscissas $a$ and $b$.
The parabola $y=(x-a)(x-b)-\frac{1}{2}$ is obtained by translating parabola (1) downward by $\frac{1}{2}$ unit (as shown in parabola (2) in Figure 4), and its intersections with the $x$-axis have the abscissas $x_{1}$ and $x_{2}$.