A North Carolina judge is being hailed for the ultimate act of compassion, sentencing a man to jail... but then joining him in the cell for the entire 24-hour sentence.

District Court Judge Lou Olivera ordered Joseph Serna, a former Special Forces soldier, to jail for violating his probation, according to WRAL.

Serna did three combat tours in Afghanistan, and came home suffering from post-traumatic stress disorder, according to ABC 11. He turned to alcohol, which led to a DWI charge -- and that, in turn, led him to a treatment program in Olivera's court, the station said.

Earlier this month, Serna admitted in court that he lied about the results of a urinalysis test

"Every two weeks we go to veterans court, and my urinalysis test had come back positive," Serna, 41, told the Fayetteville Observer. "I denied it at first."

The judge, a veteran of the Gulf War, ordered him to spend 24 hours in jail -- and drove him there himself.

#GoodGuy of the day, week, month and year: District Court Judge Lou Olivera... https://t.co/DLx0Ie6zNC — Ricky Stevens (@rickstevensblue) April 23, 2016

Serna was put into his cell, and the door closed. But then it opened again, and in stepped the judge.

"(Olivera) comes in, they close the door and lock it," Serna told ABC 11. "This was a one-man cell so we sat on the bunk and I said 'you are here for the entire time with me?' he said, 'yeah that's what I am doing.'"

The two spent the night speaking about their military service.

"It was more of a father-son conversation as opposed to a judge talking to someone and sentencing them," Serna told WRAL. "It was personal."

Olivera told the Observer he was reminded of a story he once read:

"It talked about a soldier with PTSD in a hole. A family member, a therapist and a friend all throw down a rope to help the veteran suffering. Finally, a fellow veteran climbs into the hole with him. The soldier suffering with PTSD asks, 'Why are you down here?' The fellow veteran replied, 'I am here to climb out with you.'"

"I thought about that story when Joe walked in shaking," Olivera told the newspaper. "I do know that many veterans would have done the same. They would have gotten in the hole to help. And so did I."

Rocio Serna, Serna's wife and a veteran herself, told the Observer she's already seen changes in her husband.

"When he told me this story, I was in disbelief," she says. "I said, 'No way.' The judge even bought doughnuts for the family when they came home."

Olivera said he also came away from the experience with something.

"When they close that door, it's really, you are shut off," he told ABC 11. "I had more... understanding of the issues Joe was going through."

A Facebook page set up in 2006 for Olivera's efforts to be elected to the court has in recent days been flooded with messages of support.

"You SIR are a class act, thank you for helping a fellow vet," wrote Bob Padilla. "We need more Judges like you."