@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { String measurementsClassReference = "Phenotips.MeasurementsClass"; Query q = session.createQuery("select p from " + IntegerProperty.class.getName() + " as p, BaseObject as o" + " where o.className='" + measurementsClassReference + "' and p.id.id=o.id and p.id.name='age'"); @SuppressWarnings("unchecked") List<IntegerProperty> oldAgeProperties = q.list(); for (IntegerProperty oldAgeProperty : oldAgeProperties) { FloatProperty newAgeProperty = new FloatProperty(); newAgeProperty.setId(oldAgeProperty.getId()); newAgeProperty.setName(oldAgeProperty.getName()); Integer oldValue = (Integer) oldAgeProperty.getValue(); if (oldValue != null) { newAgeProperty.setValue((float) oldValue); } session.delete(oldAgeProperty); session.save(newAgeProperty); } return null; } }
@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { String measurementsClassReference = "Phenotips.MeasurementsClass"; Query q = session.createQuery("select p from " + IntegerProperty.class.getName() + " as p, BaseObject as o" + " where o.className='" + measurementsClassReference + "' and p.id.id=o.id and p.id.name='age'"); @SuppressWarnings("unchecked") List<IntegerProperty> oldAgeProperties = q.list(); for (IntegerProperty oldAgeProperty : oldAgeProperties) { FloatProperty newAgeProperty = new FloatProperty(); newAgeProperty.setId(oldAgeProperty.getId()); newAgeProperty.setName(oldAgeProperty.getName()); Integer oldValue = (Integer) oldAgeProperty.getValue(); if (oldValue != null) { newAgeProperty.setValue((float) oldValue); } session.delete(oldAgeProperty); session.save(newAgeProperty); } return null; } }