// Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.

package org.melati.poem.generated;


import org.melati.poem.AccessPoemException;
import org.melati.poem.Column;
import org.melati.poem.Field;
import org.melati.poem.Group;
import org.melati.poem.GroupMembershipTable;
import org.melati.poem.JdbcPersistent;
import org.melati.poem.NoSuchRowPoemException;
import org.melati.poem.PoemDatabaseTables;
import org.melati.poem.User;
import org.melati.poem.ValidationPoemException;


/**
 * Melati POEM generated abstract base class for a <code>Persistent</code> 
 * <code>groupMembership</code> Object.
 *
 * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
 */
public abstract class GroupMembershipBase extends JdbcPersistent {


 /**
  * Retrieves the Database object.
  * 
  * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
  * @return the database
  */
  public PoemDatabaseTables getPoemDatabaseTables() {
    return (PoemDatabaseTables)getDatabase();
  }


 /**
  * Retrieves the  <code>GroupMembershipTable</code> table 
  * which this <code>Persistent</code> is from.
  * 
  * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
  * @return the GroupMembershipTable
  */
  public GroupMembershipTable getGroupMembershipTable() {
    return (GroupMembershipTable)getTable();
  }

  private GroupMembershipTable _getGroupMembershipTable() {
    return (GroupMembershipTable)getTable();
  }

  // Fields in this table 
 /**
  * id - The Table Row Object ID 
  */
  protected Integer id;
 /**
  * User - The user who belongs to the group 
  */
  protected Integer user;
 /**
  * Group - The group to which the user belongs 
  */
  protected Integer group;


 /**
  * Retrieves the <code>Id</code> value, without locking, 
  * for this <code>groupMembership</code> <code>Persistent</code>.
  *
  * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
  * @return the Integer id
  */
  public Integer getId_unsafe() {
    return id;
  }


 /**
  * Sets the <code>Id</code> value directly, without checking, 
  * for this groupMembership <code>Persistent</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
  * @param cooked  the pre-validated value to set
  */
  public void setId_unsafe(Integer cooked) {
    id = cooked;
  }

 /**
  * Retrieves the Id value, with locking, for this 
  * <code>groupMembership</code> <code>Persistent</code>.
  * Field description: 
  *   The Table Row Object ID 
  * 
  * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
  * @throws AccessPoemException 
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights 
  * @return the value of the field <code>Id</code> for this 
  *         <code>groupMembership</code> <code>Persistent</code>  
  */

  public Integer getId()
      throws AccessPoemException {
    readLock();
    return getId_unsafe();
  }


 /**
  * Sets the <code>Id</code> value, with checking, for this 
  * <code>groupMembership</code> <code>Persistent</code>.
  * Field description: 
  *   The Table Row Object ID 
  * 
  * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
  * @param cooked  a validated <code>int</code> 
  * @throws AccessPoemException 
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights
  * @throws ValidationPoemException 
  *         if the value is not valid
  */
  public void setId(Integer cooked)
      throws AccessPoemException, ValidationPoemException {
    _getGroupMembershipTable().getIdColumn().
      getType().assertValidCooked(cooked);
    writeLock();
    setId_unsafe(cooked);
  }

 /**
  * Sets the <code>Id</code> value, with checking, for this 
  * <code>groupMembership</code> <code>Persistent</code>.
  * Field description: 
  *   The Table Row Object ID 
  * 
  * 
  * Generated by org.melati.poem.prepro.IntegerFieldDef#generateBaseMethods 
  * @param cooked  a validated <code>int</code>
  * @throws AccessPoemException 
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights
  * @throws ValidationPoemException 
  *         if the value is not valid
  */

  public final void setId(int cooked)
      throws AccessPoemException, ValidationPoemException {
    setId(new Integer(cooked));
  }


 /**
  * Retrieves the <code>Id</code> value as a <code>Field</code>
  * from this <code>groupMembership</code> <code>Persistent</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
  * @throws AccessPoemException 
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights
  * @return the Integer id
  */
  public Field<Integer> getIdField() throws AccessPoemException {
    Column<Integer> c = _getGroupMembershipTable().getIdColumn();
    return new Field<Integer>((Integer)c.getRaw(this), c);
  }


 /**
  * Retrieves the <code>User</code> value, without locking, 
  * for this <code>groupMembership</code> <code>Persistent</code>.
  *
  * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
  * @return the Integer user
  */
  public Integer getUser_unsafe() {
    return user;
  }


 /**
  * Sets the <code>User</code> value directly, without checking, 
  * for this groupMembership <code>Persistent</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
  * @param cooked  the pre-validated value to set
  */
  public void setUser_unsafe(Integer cooked) {
    user = cooked;
  }

 /**
  * Retrieves the Table Row Object ID. 
  *
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer read access rights 
  * @return the TROID as an <code>Integer</code> 
  */

  public Integer getUserTroid()
      throws AccessPoemException {
    readLock();
    return getUser_unsafe();
  }


 /**
  * Sets the Table Row Object ID. 
  * 
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @param raw  a Table Row Object Id 
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights
  */
  public void setUserTroid(Integer raw)
      throws AccessPoemException {
    setUser(raw == null ? null : 
        getPoemDatabaseTables().getUserTable().getUserObject(raw));
  }


 /**
  * Retrieves the <code>User</code> object referred to.
  *  
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer read access rights 
  * @throws NoSuchRowPoemException  
  *         if the <code>Persistent</code> has yet to be allocated a TROID 
  * @return the <code>User</code> as a <code>User</code> 
  */
  public User getUser()
      throws AccessPoemException, NoSuchRowPoemException {
    Integer troid = getUserTroid();
    return troid == null ? null :
        getPoemDatabaseTables().getUserTable().getUserObject(troid);
  }


 /**
  * Set the User.
  * 
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @param cooked  a validated <code>User</code>
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights 
  */
  public void setUser(User cooked)
      throws AccessPoemException {
    _getGroupMembershipTable().
      getUserColumn().
        getType().assertValidCooked(cooked);
    writeLock();
    if (cooked == null)
      setUser_unsafe(null);
    else {
      cooked.existenceLock();
      setUser_unsafe(cooked.troid());
    }
  }


 /**
  * Retrieves the <code>User</code> value as a <code>Field</code>
  * from this <code>groupMembership</code> <code>Persistent</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
  * @throws AccessPoemException 
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights
  * @return the Integer user
  */
  public Field<Integer> getUserField() throws AccessPoemException {
    Column<Integer> c = _getGroupMembershipTable().getUserColumn();
    return new Field<Integer>((Integer)c.getRaw(this), c);
  }


 /**
  * Retrieves the <code>Group</code> value, without locking, 
  * for this <code>groupMembership</code> <code>Persistent</code>.
  *
  * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
  * @return the Integer group
  */
  public Integer getGroup_unsafe() {
    return group;
  }


 /**
  * Sets the <code>Group</code> value directly, without checking, 
  * for this groupMembership <code>Persistent</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
  * @param cooked  the pre-validated value to set
  */
  public void setGroup_unsafe(Integer cooked) {
    group = cooked;
  }

 /**
  * Retrieves the Table Row Object ID. 
  *
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer read access rights 
  * @return the TROID as an <code>Integer</code> 
  */

  public Integer getGroupTroid()
      throws AccessPoemException {
    readLock();
    return getGroup_unsafe();
  }


 /**
  * Sets the Table Row Object ID. 
  * 
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @param raw  a Table Row Object Id 
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights
  */
  public void setGroupTroid(Integer raw)
      throws AccessPoemException {
    setGroup(raw == null ? null : 
        getPoemDatabaseTables().getGroupTable().getGroupObject(raw));
  }


 /**
  * Retrieves the <code>Group</code> object referred to.
  *  
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer read access rights 
  * @throws NoSuchRowPoemException  
  *         if the <code>Persistent</code> has yet to be allocated a TROID 
  * @return the <code>Group</code> as a <code>Group</code> 
  */
  public Group getGroup()
      throws AccessPoemException, NoSuchRowPoemException {
    Integer troid = getGroupTroid();
    return troid == null ? null :
        getPoemDatabaseTables().getGroupTable().getGroupObject(troid);
  }


 /**
  * Set the Group.
  * 
  * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
  * @param cooked  a validated <code>Group</code>
  * @throws AccessPoemException  
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights 
  */
  public void setGroup(Group cooked)
      throws AccessPoemException {
    _getGroupMembershipTable().
      getGroupColumn().
        getType().assertValidCooked(cooked);
    writeLock();
    if (cooked == null)
      setGroup_unsafe(null);
    else {
      cooked.existenceLock();
      setGroup_unsafe(cooked.troid());
    }
  }


 /**
  * Retrieves the <code>Group</code> value as a <code>Field</code>
  * from this <code>groupMembership</code> <code>Persistent</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
  * @throws AccessPoemException 
  *         if the current <code>AccessToken</code> 
  *         does not confer write access rights
  * @return the Integer group
  */
  public Field<Integer> getGroupField() throws AccessPoemException {
    Column<Integer> c = _getGroupMembershipTable().getGroupColumn();
    return new Field<Integer>((Integer)c.getRaw(this), c);
  }

}

