@Override public long save(Box box) throws IOException { if (!box.isSaved()) { return (long) currentSession().save(box); } else { currentSession().update(box); // flush required to avoid constraint violation incase removed items are immediately added to another box or the same one // NOTE: this flush will cause ALL Hibernate-managed items to be saved to the db in their current state, even if their `save` method // hasn't explicitly been called yet currentSession().flush(); return box.getId(); } }
if (!box.isSaved()) { return saveNewBox(box); } else {