⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseuser1.java

📁 这是基于struts的用户登录程序
💻 JAVA
字号:
package org.apache.struts.webapp.example.model;import java.math.BigDecimal;import java.sql.Connection;import java.util.ArrayList;import java.util.Date;import java.util.Collections;import java.util.List;import org.apache.commons.lang.ObjectUtils;import org.apache.torque.TorqueException;import org.apache.torque.om.BaseObject;import org.apache.torque.om.ComboKey;import org.apache.torque.om.DateKey;import org.apache.torque.om.NumberKey;import org.apache.torque.om.ObjectKey;import org.apache.torque.om.SimpleKey;import org.apache.torque.om.StringKey;import org.apache.torque.om.Persistent;import org.apache.torque.util.Criteria;import org.apache.torque.util.Transaction;/** * This class was autogenerated by Torque on: * * [Tue May 02 23:05:41 CST 2006] * * You should not use this class directly.  It should not even be * extended all references should be to User1 */public abstract class BaseUser1 extends BaseObject{    /** The Peer class */    private static final User1Peer peer =        new User1Peer();            /** The value for the id field */    private int id;          /** The value for the username field */    private String username;          /** The value for the fullName field */    private String fullName;          /** The value for the password field */    private String password;          /** The value for the fromAddress field */    private String fromAddress;          /** The value for the replyToAddress field */    private String replyToAddress;          /**     * Get the Id     *     * @return int     */    public int getId()    {        return id;    }                            /**     * Set the value of Id     *     * @param v new value     */    public void setId(int v)     {                      if (this.id != v)              {            this.id = v;            setModified(true);        }                            }      /**     * Get the Username     *     * @return String     */    public String getUsername()    {        return username;    }                            /**     * Set the value of Username     *     * @param v new value     */    public void setUsername(String v)     {                      if (!ObjectUtils.equals(this.username, v))              {            this.username = v;            setModified(true);        }                            }      /**     * Get the FullName     *     * @return String     */    public String getFullName()    {        return fullName;    }                            /**     * Set the value of FullName     *     * @param v new value     */    public void setFullName(String v)     {                      if (!ObjectUtils.equals(this.fullName, v))              {            this.fullName = v;            setModified(true);        }                            }      /**     * Get the Password     *     * @return String     */    public String getPassword()    {        return password;    }                            /**     * Set the value of Password     *     * @param v new value     */    public void setPassword(String v)     {                      if (!ObjectUtils.equals(this.password, v))              {            this.password = v;            setModified(true);        }                            }      /**     * Get the FromAddress     *     * @return String     */    public String getFromAddress()    {        return fromAddress;    }                            /**     * Set the value of FromAddress     *     * @param v new value     */    public void setFromAddress(String v)     {                      if (!ObjectUtils.equals(this.fromAddress, v))              {            this.fromAddress = v;            setModified(true);        }                            }      /**     * Get the ReplyToAddress     *     * @return String     */    public String getReplyToAddress()    {        return replyToAddress;    }                            /**     * Set the value of ReplyToAddress     *     * @param v new value     */    public void setReplyToAddress(String v)     {                      if (!ObjectUtils.equals(this.replyToAddress, v))              {            this.replyToAddress = v;            setModified(true);        }                            }                               private static List fieldNames = null;    /**     * Generate a list of field names.     *     * @return a list of field names     */    public static synchronized List getFieldNames()    {        if (fieldNames == null)        {            fieldNames = new ArrayList();              fieldNames.add("Id");              fieldNames.add("Username");              fieldNames.add("FullName");              fieldNames.add("Password");              fieldNames.add("FromAddress");              fieldNames.add("ReplyToAddress");              fieldNames = Collections.unmodifiableList(fieldNames);        }        return fieldNames;    }    /**     * Retrieves a field from the object by name passed in as a String.     *     * @param name field name     * @return value     */    public Object getByName(String name)    {          if (name.equals("Id"))        {                return new Integer(getId());            }          if (name.equals("Username"))        {                return getUsername();            }          if (name.equals("FullName"))        {                return getFullName();            }          if (name.equals("Password"))        {                return getPassword();            }          if (name.equals("FromAddress"))        {                return getFromAddress();            }          if (name.equals("ReplyToAddress"))        {                return getReplyToAddress();            }          return null;    }        /**     * Retrieves a field from the object by name passed in     * as a String.  The String must be one of the static     * Strings defined in this Class' Peer.     *     * @param name peer name     * @return value     */    public Object getByPeerName(String name)    {          if (name.equals(User1Peer.ID))        {                return new Integer(getId());            }          if (name.equals(User1Peer.USERNAME))        {                return getUsername();            }          if (name.equals(User1Peer.FULLNAME))        {                return getFullName();            }          if (name.equals(User1Peer.PASSWORD))        {                return getPassword();            }          if (name.equals(User1Peer.FROMADDRESS))        {                return getFromAddress();            }          if (name.equals(User1Peer.REPLYTOADDRESS))        {                return getReplyToAddress();            }          return null;    }    /**     * Retrieves a field from the object by Position as specified     * in the xml schema.  Zero-based.     *     * @param pos position in xml schema     * @return value     */    public Object getByPosition(int pos)    {            if (pos == 0)        {                return new Integer(getId());            }              if (pos == 1)        {                return getUsername();            }              if (pos == 2)        {                return getFullName();            }              if (pos == 3)        {                return getPassword();            }              if (pos == 4)        {                return getFromAddress();            }              if (pos == 5)        {                return getReplyToAddress();            }              return null;    }         /**     * Stores the object in the database.  If the object is new,     * it inserts it; otherwise an update is performed.     *     * @throws Exception     */    public void save() throws Exception    {          save(User1Peer.getMapBuilder()                .getDatabaseMap().getName());      }    /**     * Stores the object in the database.  If the object is new,     * it inserts it; otherwise an update is performed.       * Note: this code is here because the method body is     * auto-generated conditionally and therefore needs to be     * in this file instead of in the super class, BaseObject.       *     * @param dbName     * @throws TorqueException     */    public void save(String dbName) throws TorqueException    {        Connection con = null;          try        {            con = Transaction.begin(dbName);            save(con);            Transaction.commit(con);        }        catch(TorqueException e)        {            Transaction.safeRollback(con);            throw e;        }      }      /** flag to prevent endless save loop, if this object is referenced        by another object which falls in this transaction. */    private boolean alreadyInSave = false;      /**     * Stores the object in the database.  If the object is new,     * it inserts it; otherwise an update is performed.  This method     * is meant to be used as part of a transaction, otherwise use     * the save() method and the connection details will be handled     * internally     *     * @param con     * @throws TorqueException     */    public void save(Connection con) throws TorqueException    {          if (!alreadyInSave)        {            alreadyInSave = true;              // If this object has been modified, then save it to the database.            if (isModified())            {                if (isNew())                {                    User1Peer.doInsert((User1) this, con);                    setNew(false);                }                else                {                    User1Peer.doUpdate((User1) this, con);                }            }                      alreadyInSave = false;        }      }                          /**     * Set the PrimaryKey using ObjectKey.     *     * @param  id ObjectKey     */    public void setPrimaryKey(ObjectKey key)            {            setId(((NumberKey) key).intValue());        }    /**     * Set the PrimaryKey using a String.     *     * @param key     */    public void setPrimaryKey(String key)     {            setId(Integer.parseInt(key));        }      /**     * returns an id that differentiates this object from others     * of its class.     */    public ObjectKey getPrimaryKey()    {          return SimpleKey.keyFor(getId());      }     /**     * Makes a copy of this object.     * It creates a new object filling in the simple attributes.       * It then fills all the association collections and sets the     * related objects to isNew=true.       */      public User1 copy() throws TorqueException    {        return copyInto(new User1());    }      protected User1 copyInto(User1 copyObj) throws TorqueException    {          copyObj.setId(id);          copyObj.setUsername(username);          copyObj.setFullName(fullName);          copyObj.setPassword(password);          copyObj.setFromAddress(fromAddress);          copyObj.setReplyToAddress(replyToAddress);                      copyObj.setId(0);                                                          return copyObj;    }    /**     * returns a peer instance associated with this om.  Since Peer classes     * are not to have any instance attributes, this method returns the     * same instance for all member of this class. The method could therefore     * be static, but this would prevent one from overriding the behavior.     */    public User1Peer getPeer()    {        return peer;    }    public String toString()    {        StringBuffer str = new StringBuffer();        str.append("User1:\n");        str.append("Id = ")           .append(getId())           .append("\n");        str.append("Username = ")           .append(getUsername())           .append("\n");        str.append("FullName = ")           .append(getFullName())           .append("\n");        str.append("Password = ")           .append(getPassword())           .append("\n");        str.append("FromAddress = ")           .append(getFromAddress())           .append("\n");        str.append("ReplyToAddress = ")           .append(getReplyToAddress())           .append("\n");        return(str.toString());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -