if(personAccount == null){ personAccount = new PersonAccount(guide.getPerson()); sp.getIPersistentPersonAccount().simpleLockWrite(personAccount); }
    public void run(Integer guideEntryID, IUserView userView) throws ExcepcaoPersistencia {        ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();        IGuideEntry guideEntry = (IGuideEntry) sp.getIPersistentGuideEntry().readByOID(GuideEntry.class,                guideEntryID);        IGuide guide = guideEntry.getGuide();        IStudent student = sp.getIPersistentStudent().readByPersonAndDegreeType(guide.getPerson(),                DegreeType.MASTER_DEGREE);        IGratuitySituation gratuitySituation = sp.getIPersistentGratuitySituation()                .readGratuitySituationByExecutionDegreeAndStudent(guide.getExecutionDegree().getIdInternal(), student.getIdInternal());        IPersonAccount personAccount = sp.getIPersistentPersonAccount().readByPerson(guide.getPerson().getIdInternal());        IPerson responsible = sp.getIPessoaPersistente().lerPessoaPorUsername(userView.getUtilizador());        Double value = new Double(guideEntry.getPrice().doubleValue()                * guideEntry.getQuantity().intValue());        IGratuityTransaction gratuityTransaction = new GratuityTransaction(value, new Timestamp(Calendar                .getInstance().getTimeInMillis()), guideEntry.getDescription(), guide.getPaymentType(),                TransactionType.GRATUITY_ADHOC_PAYMENT, Boolean.FALSE, responsible, personAccount,                guideEntry, gratuitySituation);        sp.getIPersistentGratuityTransaction().lockWrite(gratuityTransaction);        // Update GratuitySituation        sp.getIPersistentGratuitySituation().lockWrite(gratuitySituation);        Double remainingValue = gratuitySituation.getRemainingValue();        gratuitySituation.setRemainingValue(new Double(remainingValue.doubleValue()                - value.doubleValue()));    }