Beispiel #1
0
  @Override
  public void renameObservableProperty(String oldName, String newName)
      throws OwsExceptionReport, NoSuchObservablePropertyException {
    Session s = null;
    Transaction t = null;
    try {
      s = sessionHolder.getSession();
      t = s.beginTransaction();
      ObservableProperty op =
          (ObservableProperty)
              s.createCriteria(ObservableProperty.class)
                  .add(Restrictions.eq(ObservableProperty.IDENTIFIER, oldName))
                  .uniqueResult();

      if (op == null) {
        throw new NoSuchObservablePropertyException(oldName);
      }
      op.setIdentifier(newName);
      s.update(op);
      s.flush();
      t.commit();
    } catch (HibernateException he) {
      if (t != null) {
        t.rollback();
      }
      throw he;
    } finally {
      sessionHolder.returnSession(s);
    }
  }