"A member of the public can't wander on to a school and that's the whole point," he said.
It is alleged the teacher was caught in a compromising position by students in June last year but the lawyer said his client was in a second-floor classroom with the door closed at the time.
Mr Earwaker said the witness was "boosted" into a position to see the defendant.
But the hearing stalled when police asked for time to bring a staff member from the school to court to give evidence.
Eventually, Judge Ajit Singh adjourned the hearing until next month because it was "an important case and could have precedent value".
Both he and the lawyers said they had never come across a scenario where this specific area of the law had been tested.
A representative of the school - which is also suppressed - will give evidence at the next hearing and will be cross-examined about school policy before the judge decides whether the matter will progress to trial.
The teacher was suspended by the school after the incident before resigning the following month.
The New Zealand Teachers Council confirmed the man had signed a voluntary undertaking not to teach, but had been suspended anyway.