IPessoa person = (IPessoa) sp.getIPessoaPersistente() .readByOID(Pessoa.class, student.getPerson().getIdInternal(), true); person.setUsername("M" + student.getNumber()); student.setPerson(person);
sp.getIPessoaPersistente().simpleLockWrite(student.getPerson()); student.getPerson().setUsername("M" + student.getNumber());
    private void changeUsernameIfNeccessary(IStudent student)            throws ExcepcaoPersistencia {        try {            SuportePersistenteOJB sp = SuportePersistenteOJB.getInstance();            if ((student.getPerson().getUsername().indexOf("Mes") != -1)                    || (student.getPerson().getUsername().indexOf("Esp") != -1)                    || (student.getPerson().getUsername().indexOf("Int") != -1)) {                IPessoa person = (IPessoa) sp.getIPessoaPersistente()                        .readByOID(Pessoa.class,                                student.getPerson().getIdInternal(), true);                person.setUsername("M" + student.getNumber());                student.setPerson(person);            }        } catch (ExcepcaoPersistencia e) {            throw new ExcepcaoPersistencia();        }    }