MeasurementSchedule sched = def.getSchedules().get(0);
Resource resource = sched.getResource();
int resourceId = resource.getId();
MeasurementDataPK pk = new MeasurementDataPK(sched.getId());
MeasurementDataTrait mdt = new MeasurementDataTrait(pk, "Hello World");
em.persist(mdt);
em.flush();
Query q = em.createNamedQuery(MeasurementDataTrait.FIND_CURRENT_FOR_RESOURCE);
q.setParameter("resourceId", resourceId);
List<Object[]> res = q.getResultList();
System.out.println("testTraitQuery: found " + res.size() + " item(s)");
if (res.size() > 0) {
MeasurementDataTrait foo = (MeasurementDataTrait) res.get(0)[0];
String name = (String) res.get(0)[1];
System.out.println(" and it is " + foo.toString() + " and name " + name);
}
Query q2 = em.createNamedQuery(MeasurementDataTrait.FIND_CURRENT_FOR_SCHEDULES);
List<Integer> ids = new ArrayList<Integer>();
ids.add(1);