@Override public String getProperty(String key) { Session s = sessionFactory.openSession(); s.beginTransaction(); AgentState property = (AgentState) s.get(AgentState.class, agent.getID().toString() + "-" + key + "-" + getTime()); s.getTransaction().commit(); s.close(); return property != null ? property.getValue() : null; }
@SuppressWarnings("unchecked") @Override public Map<String, String> getProperties() { Session s = sessionFactory.openSession(); s.beginTransaction(); List<AgentState> propertyList = s.createQuery("from AgentState where agentId = ? and timestep = ?") .setParameter(0, agent.getID().toString()) .setParameter(1, time) .list(); Map<String, String> properties = new HashMap<String, String>(); for (AgentState p : propertyList) { properties.put(p.getName(), p.getValue()); } s.close(); return properties; }