@Override public final void saveAmount(int energy, int food, int smithore, int crystite) { if (record == null) { populateRecord(); } record.setEnergy(energy); record.setFood(food); record.setSmithore(smithore); record.setCrystite(crystite); persist(); }
@Override public final void savePrice( int energyPrice, int foodPrice, int smithorePrice, int crystitePrice) { if (record == null) { populateRecord(); } record.setEnergyPrice(energyPrice); record.setFoodPrice(foodPrice); record.setSmithorePrice(smithorePrice); record.setCrystitePrice(crystitePrice); persist(); }
@Override public final void setMuleCount(int muleCount) { if (record == null) { populateRecord(); } record.setMuleCount(muleCount); persist(); }
private void populateRecord() { Session session = sessionFactory.openSession(); String hqlString = String.format( "FROM StoreRecord SR WHERE SR.gameSaveMeta.id = %d", gameSaveMetaHolder.getGameSaveMeta().getId()); Query query = session.createQuery(hqlString); List<data.concretesources.StoreRecord> list = query.list(); if (list == null || list.size() < 1) { record = new data.concretesources.StoreRecord(); record.setGameSaveMeta(gameSaveMetaHolder.getGameSaveMeta()); } else { record = list.get(0); } session.close(); }
@Override public final int getFood() { populateRecord(); return record.getFood(); }
@Override public final int getMuleCount() { populateRecord(); return record.getMuleCount(); }
@Override public final int getCrystitePrice() { populateRecord(); return record.getCrystitePrice(); }
@Override public final int getSmithorePrice() { populateRecord(); return record.getSmithorePrice(); }
@Override public final int getEnergyPrice() { populateRecord(); return record.getEnergyPrice(); }