Esempio 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");
    }
  }
Esempio n. 2
0
 /**
  * createCopy() Creates a DO that has no ObjectId but has a copy of an existing DO's data. Such a
  * DO is used to insert a new database entry that is largely similar to an existing entry.
  *
  * @param orig The original DO to copy.
  * @exception com.lutris.appserver.server.sql.ObjectIdException If an object id can't be allocated
  *     for this object.
  * @exception DatabaseManagerException If a connection to the database cannot be established, etc.
  */
 public static PersonalProfileDO createCopy(PersonalProfileDO orig)
     throws DatabaseManagerException, ObjectIdException {
   PersonalProfileDO ret = new PersonalProfileDO();
   if (null != orig.data) {
     ret.data = (PersonalProfileDataStruct) orig.data.duplicate();
   }
   return ret;
 }
Esempio n. 3
0
 /**
  * createExisting( ResultSet )
  *
  * <p>Factory method used to create an instance of this class to represent a Data Object already
  * existing in the database.
  *
  * @param rs The ResultSet returned by the Query class for an existing Data Object stored in the
  *     database.
  * @exception DataObjectException If the object is not found in the database.
  * @exception com.lutris.appserver.server.sql.ObjectIdException If an object id can't be allocated
  *     for this object.
  * @exception DatabaseManagerException If a connection to the database cannot be established, etc.
  * @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.
  */
 protected static PersonalProfileDO createExisting(ResultSet rs)
     throws SQLException, ObjectIdException, DataObjectException, DatabaseManagerException {
   if (null == rs) return null;
   PersonalProfileDO ret = null;
   if (isView) {
     ret = new PersonalProfileDO();
     ret.initFromResultSet(rs);
   } else {
     ret = new PersonalProfileDO(rs);
   }
   return ret;
 }
Esempio n. 4
0
 /**
  * createExisting( ObjectId )
  *
  * <p>Factory method creates a PersonalProfileDO object by searching for it in the database using
  * the passed ObjectID value as the primary key.
  *
  * @param id The ObjectId for the object.
  * @exception DataObjectException If the object is not found in the database.
  * @exception com.lutris.appserver.server.sql.ObjectIdException If an object id can't be allocated
  *     for this object.
  * @exception DatabaseManagerException If a connection to the database cannot be established, etc.
  * @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.
  */
 protected static PersonalProfileDO createExisting(ObjectId id)
     throws SQLException, ObjectIdException, DataObjectException, DatabaseManagerException {
   if (null == id) return null;
   PersonalProfileDO ret = null;
   ret = new PersonalProfileDO(id);
   ret.setPersistent(true); // mark DO as persistent (preexisting)
   if (!false) // If not lazy-loading, fetch DO data now.
   ret.loadData();
   // unset the GenericDO.dirty flag.
   ret.markClean();
   return ret;
 }
Esempio n. 5
0
 /**
  * createCopy() Creates a DO that has no ObjectId but has a copy of an existing DO's data. Such a
  * DO is used to insert a new database entry that is largely similar to an existing entry.
  *
  * @param data The data struct to copy values from.
  * @exception com.lutris.appserver.server.sql.ObjectIdException If an object id can't be allocated
  *     for this object.
  * @exception DatabaseManagerException If a connection to the database cannot be established, etc.
  */
 public static PersonalProfileDO createCopy(PersonalProfileDataStruct data)
     throws DatabaseManagerException, ObjectIdException {
   PersonalProfileDO ret = new PersonalProfileDO();
   ret.data = (PersonalProfileDataStruct) data.duplicate();
   return ret;
 }