if (log.isDebugEnabled()) {
log.debug("Persisting entity " + entity.getClass().getName());
}
/** dont forget to prepare changed entities e.g. set current user */
PrepareChangesForPersist prep = new PrepareChangesForPersist(user.getUsername());
/** firstly, we set the project state to requiredPlanState */
prep.prepare(selectedPlan.getState());
selectedPlan.getState().setValue(requiredPlanState);
em.persist(em.merge(selectedPlan.getState()));
/** secondly, we save the intended entity */
prep.prepare(entity);
em.persist(em.merge(entity));
em.flush();
if (selectedPlan.getPlanProperties().getReportUpload().isDataExistent()) {
selectedPlan.getPlanProperties().setReportUpload(new DigitalObject());