コード例 #1
0
  /**
   * {@inheritDoc}
   *
   * @throws PrincipalNullException
   */
  public void save(Object object) throws PrincipalNullException {
    if (object instanceof Auditable) {
      ((Auditable) object).setCreateDate(new Timestamp((new Date()).getTime()));
      ((Auditable) object).setCreateUser(SecurityContextHelper.getRemoteUser());
      ((Auditable) object).setUpdateDate(((Auditable) object).getCreateDate());
      ((Auditable) object).setUpdateUser(((Auditable) object).getCreateUser());
    } else if (object instanceof Traceable) {
      ((Traceable) object).setCreateDate(new Timestamp((new Date()).getTime()));
      ((Traceable) object).setCreateUser(SecurityContextHelper.getRemoteUser());
    }

    if (object instanceof Versionable) {
      ((Versionable) object).setVersion(1);
    }

    Session sess = getSession();
    sess.save(object);
  }
コード例 #2
0
  /**
   * {@inheritDoc}
   *
   * @throws PrincipalNullException
   */
  public void update(Object object) throws PrincipalNullException {

    if (object instanceof Auditable) {
      ((Auditable) object).setUpdateDate(new Timestamp((new Date()).getTime()));
      ((Auditable) object).setUpdateUser(SecurityContextHelper.getRemoteUser());
    }

    Session sess = getSession();
    sess.update(object);
  }