Exemplo n.º 1
0
  /**
   * loadData() Load the fields for the DO from the database.
   *
   * @exception com.lutris.appserver.server.sql.ObjectIdException If an object id can't be allocated
   *     for this object.
   * @exception DataObjectException If the object is not found in the database.
   * @exception SQLException If the database rejects the SQL generated to retrieve data for this
   *     object, or if the table contains a bad foreign key, etc.
   */
  public void loadData() throws SQLException, ObjectIdException, DataObjectException {
    if (null == data) {
      super.loadData();
      data = new PersonalProfileDataStruct();
    }

    ObjectId id = getOId();
    if (null == id) return;
    if (!isPersistent()) // DO from createVirgin
    return;

    // DO from createExisting.  Complain if no record in database.
    PersonalProfileQuery query = new PersonalProfileQuery();
    query.setQueryOId(id);
    query.requireUniqueInstance();
    PersonalProfileDO obj;
    try {
      obj = query.getNextDO();
      if (null == obj) throw new DataObjectException("PersonalProfileDO DO not found for id=" + id);
      makeIdentical(obj);
      setVersion(obj.getVersion());
      setNewVersion(obj.getVersion());

    } catch (NonUniqueQueryException e) {
      throw new ObjectIdException("Duplicate ObjectId");
    }
  }