A man has been imprisoned for seven years after grabbing a prison officer's bum.

A man who grabbed a prison officer on her bum has been sentenced to seven years in prison.

The length of the sentence for the offence involved - and the legislation that enforces it - has earned stern criticism from sentencing judge Kit Toogood.

Auckland man Raven Casey Campbell, 25, was facing the distinct possibility of having to serve out the full term of his sentence, with no chance of parole, when he appeared for sentence in the High Court in Hamilton on Thursday.

MIKE MATHER/FAIRFAX NZ Raven Campbell, 25, was sentenced in the High Court in Hamilton on Thursday morning.

Campbell had committed two violent offences previously - and was now on his third strike, meaning he would have to serve out the full term of the maximum available sentence.

The maximum for indecent assault is seven years.

It was the first time a "third-strike" sentencing has been imposed under the law, brought in six years ago.

On considering submissions from defence counsel Thomas Sutcliffe and Crown prosecutor Rebecca Mann - as well as letters written to the court and the prison officer by Campbell himself - Justice Kit Toogood opted to refrain from imposing the full available sentence for the crime.

That crime happened in Waikeria Prison on May 17 this year, where Campbell had been serving a three year, four month sentence for an aggravated robbery, for which he had been convicted in April 2014.

A female Corrections officer had been supervising prisoners in an area called the kit locker, where they exchange their clothing, towels and bedding for fresh items.

Campbell approached the officer from behind and grabbed her right buttock, squeezing it hard, and holding on for about one to two seconds.

"You were told to go to the guard room but you did not make any attempt to move," Justice Toogood told Campbell.

"When the Corrections officer went to leave the yard through a set of steel gates, you followed her, grabbed the gate, and asked if you could talk to her."

Campbell was told to move, and he did so. But his actions had already had an effect: The prison officer was distressed by the bottom grabbing incident and consequently had to take time off from work.

"You have said that you really liked the officer, that you grabbed her as a bit of a joke and you thought your actions would be taken that way," Toogood said.

As well as his aggravated robbery, Campbell had been convicted of robbery and demanding to steal in 2013 - offences that earned him a stage one warning to accompany his sentence of community work and supervision.

The judge had to carefully consider whether the full penalty should be applied.

"I have read your letters to the court and to the victim. They are thoughtful and insightful. You recognise that your behaviour was rude, disrespectful and immoral. You acknowledge that you made a stupid and thoughtless decision and say that you have learned a huge lesson.

"I sense that your remorse is genuine.

"I have no option but to sentence you to the maximum term of imprisonment prescribed for the offence - seven years' imprisonment. I agree that is very harsh given that what you did was not the most serious assault of its type, but Parliament has determined that your history of violent offending requires a very stern response to protect the public from you and to act as a deterrent to you and others.

"It may seem very surprising that this consequence could be required by law for an offence of this kind, but that is the law and I have no option but to enforce it.

"Were it not for the requirement to sentence you to the maximum term of seven years, the need to denounce your conduct, hold you accountable and deter others and you from such offending, it would likely have resulted in a period of no more than 12 months' imprisonment."

Toogood sentenced Campbell to seven years in prison, but Campbell is still able to apply for parole once a third of that term has passed.

Speaking after sentencing, defence counsel Sutcliffe indicated the law is an ass.

"It's an illustration as to why this is bad legislation. It's ill-considered and it needs revision.

"This consequence could not have been in the minds of right-thinking members of Parliament when the legislation was conceived. I accept that it was well-conceived and designed to keep out of circulation the worst violent offenders.

"This case is an embarrassment for the authors of that legislation, not an endorsement.

"For those critics who respond by saying I am saying this as a criminal defence lawyer, I'm also a member of the New Zealand community, and I would take this stance regardless of what my occupation is."

But ACT leader David Seymour saw the case as an example of the law working in a difficult case.

"The fact there is a safety valve that's prevented him from getting seven years is as it was intended to work," Seymour said in reference to the allowance for parole.

"If you're going to have a law and you're going to say that repeat offences are not acceptable, then you have to enforce the law.

"Sentencing is always about finding a balance. Three strikes has brought the balance back to what the public would think of as being reasonable punishment."

The "three-strikes legislation", which passed into law in June 2010 after a push from then-ACT politician David Garrett, gives people who commit violent offences "strikes" when they plead or are found guilty.

A first strike serves as a warning, and a second strike requires an offender to serve their sentence without parole.

Someone who gets a third strike must serve the maximum sentence possible without parole, unless the court considers it would be manifestly unjust.