-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: why POJO class always need implements Serializable?
PostPosted: Mon Aug 15, 2005 3:07 am 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
i write the code follow my boss:
my POJO class Jbxx implement Serializable
that my code:
Code:
public class Jbxx
    implements Serializable
{
    /** The cached hash code value for this instance.  Settting to 0 triggers re-calculation. */
    private int hashValue = 0;

    /** The composite primary key value. */
    private java.lang.String czrkryid;

    /** The value of the simple czrkssssxq property. */
    private java.lang.String czrkssssxq;

    /** The value of the simple czrkgmsfhm property. */
    private java.lang.String czrkgmsfhm;

    /** The value of the simple czrkxm property. */
    private java.lang.String czrkxm;

    /** The value of the simple czrkcym property. */
    private java.lang.String czrkcym;

    /** The value of the simple czrkxb property. */
    private java.lang.String czrkxb;

    /** The value of the simple czrkmz property. */
    private java.lang.String czrkmz;

    /** The value of the simple czrkcsrq property. */
    private java.lang.String czrkcsrq;

    /** The value of the simple czrkcsdgj property. */
    private java.lang.String czrkcsdgj;

    /** The value of the simple czrkcsdssx property. */
    private java.lang.String czrkcsdssx;

    /** The value of the simple czrkcsdxz property. */
    private java.lang.String czrkcsdxz;

    /** The value of the simple czrkjggj property. */
    private java.lang.String czrkjggj;

    /** The value of the simple czrkjgssx property. */
    private java.lang.String czrkjgssx;

    /** The value of the simple czrkwhcd property. */
    private java.lang.String czrkwhcd;

    /** The value of the simple czrkhyzk property. */
    private java.lang.String czrkhyzk;

    /** The value of the simple czrkbyzk property. */
    private java.lang.String czrkbyzk;

    /** The value of the simple czrksg property. */
    private java.lang.String czrksg;

    /** The value of the simple czrkzy property. */
    private java.lang.String czrkzy;

    /** The value of the simple czrkfwcs property. */
    private java.lang.String czrkfwcs;

    /** The value of the simple czrkzz property. */
    private java.lang.String czrkzz;

    /** The value of the simple czrkxp property. */
    private java.lang.String czrkxp;

    /** The value of the simple czrkxxjb property. */
    private java.lang.String czrkxxjb;

    /** The value of the simple czrkzxbs property. */
    private java.lang.String czrkzxbs;

    /** The value of the simple czrkxjgajgmc property. */
    private java.lang.String czrkxjgajgmc;

    /** The value of the simple czrkxjgajgjgdm property. */
    private java.lang.String czrkxjgajgjgdm;

    /** The value of the simple czrkpcsmc property. */
    private java.lang.String czrkpcsmc;

    /** The value of the simple czrkpcsjgdm property. */
    private java.lang.String czrkpcsjgdm;

    /** The value of the simple czrkxxtqsj property. */
    private java.lang.String czrkxxtqsj;

    /** The value of the simple yhbpackagename property. */
    private java.lang.String yhbpackagename;

    /** The value of the simple yhbgabtime property. */
    private java.sql.Timestamp yhbgabtime;

    /**
     * Simple constructor of AbstractJbxx instances.
     */
    public AbstractJbxx()
    {
    }

    /**
     * Constructor of AbstractJbxx instances given a simple primary key.
     * @param czrkryid
     */
    public AbstractJbxx(java.lang.String czrkryid)
    {
        this.setCzrkryid(czrkryid);
    }

    /**
     * Return the simple primary key value that identifies this object.
     * @return java.lang.String
     */
    public java.lang.String getCzrkryid()
    {
        return czrkryid;
    }

    /**
     * Set the simple primary key value that identifies this object.
     * @param czrkryid
     */
    public void setCzrkryid(java.lang.String czrkryid)
    {
        this.hashValue = 0;
        this.czrkryid = czrkryid;
    }

    /**
     * Return the value of the CZRKSSSSXQ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkssssxq()
    {
        return this.czrkssssxq;
    }

    /**
     * Set the value of the CZRKSSSSXQ column.
     * @param czrkssssxq
     */
    public void setCzrkssssxq(java.lang.String czrkssssxq)
    {
        this.czrkssssxq = czrkssssxq;
    }

    /**
     * Return the value of the CZRKGMSFHM column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkgmsfhm()
    {
        return this.czrkgmsfhm;
    }

    /**
     * Set the value of the CZRKGMSFHM column.
     * @param czrkgmsfhm
     */
    public void setCzrkgmsfhm(java.lang.String czrkgmsfhm)
    {
        this.czrkgmsfhm = czrkgmsfhm;
    }

    /**
     * Return the value of the CZRKXM column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkxm()
    {
        return this.czrkxm;
    }

    /**
     * Set the value of the CZRKXM column.
     * @param czrkxm
     */
    public void setCzrkxm(java.lang.String czrkxm)
    {
        this.czrkxm = czrkxm;
    }

    /**
     * Return the value of the CZRKCYM column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkcym()
    {
        return this.czrkcym;
    }

    /**
     * Set the value of the CZRKCYM column.
     * @param czrkcym
     */
    public void setCzrkcym(java.lang.String czrkcym)
    {
        this.czrkcym = czrkcym;
    }

    /**
     * Return the value of the CZRKXB column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkxb()
    {
        return this.czrkxb;
    }

    /**
     * Set the value of the CZRKXB column.
     * @param czrkxb
     */
    public void setCzrkxb(java.lang.String czrkxb)
    {
        this.czrkxb = czrkxb;
    }

    /**
     * Return the value of the CZRKMZ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkmz()
    {
        return this.czrkmz;
    }

    /**
     * Set the value of the CZRKMZ column.
     * @param czrkmz
     */
    public void setCzrkmz(java.lang.String czrkmz)
    {
        this.czrkmz = czrkmz;
    }

    /**
     * Return the value of the CZRKCSRQ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkcsrq()
    {
        return this.czrkcsrq;
    }

    /**
     * Set the value of the CZRKCSRQ column.
     * @param czrkcsrq
     */
    public void setCzrkcsrq(java.lang.String czrkcsrq)
    {
        this.czrkcsrq = czrkcsrq;
    }

    /**
     * Return the value of the CZRKCSDGJ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkcsdgj()
    {
        return this.czrkcsdgj;
    }

    /**
     * Set the value of the CZRKCSDGJ column.
     * @param czrkcsdgj
     */
    public void setCzrkcsdgj(java.lang.String czrkcsdgj)
    {
        this.czrkcsdgj = czrkcsdgj;
    }

    /**
     * Return the value of the CZRKCSDSSX column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkcsdssx()
    {
        return this.czrkcsdssx;
    }

    /**
     * Set the value of the CZRKCSDSSX column.
     * @param czrkcsdssx
     */
    public void setCzrkcsdssx(java.lang.String czrkcsdssx)
    {
        this.czrkcsdssx = czrkcsdssx;
    }

    /**
     * Return the value of the CZRKCSDXZ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkcsdxz()
    {
        return this.czrkcsdxz;
    }

    /**
     * Set the value of the CZRKCSDXZ column.
     * @param czrkcsdxz
     */
    public void setCzrkcsdxz(java.lang.String czrkcsdxz)
    {
        this.czrkcsdxz = czrkcsdxz;
    }

    /**
     * Return the value of the CZRKJGGJ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkjggj()
    {
        return this.czrkjggj;
    }

    /**
     * Set the value of the CZRKJGGJ column.
     * @param czrkjggj
     */
    public void setCzrkjggj(java.lang.String czrkjggj)
    {
        this.czrkjggj = czrkjggj;
    }

    /**
     * Return the value of the CZRKJGSSX column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkjgssx()
    {
        return this.czrkjgssx;
    }

    /**
     * Set the value of the CZRKJGSSX column.
     * @param czrkjgssx
     */
    public void setCzrkjgssx(java.lang.String czrkjgssx)
    {
        this.czrkjgssx = czrkjgssx;
    }

    /**
     * Return the value of the CZRKWHCD column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkwhcd()
    {
        return this.czrkwhcd;
    }

    /**
     * Set the value of the CZRKWHCD column.
     * @param czrkwhcd
     */
    public void setCzrkwhcd(java.lang.String czrkwhcd)
    {
        this.czrkwhcd = czrkwhcd;
    }

    /**
     * Return the value of the CZRKHYZK column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkhyzk()
    {
        return this.czrkhyzk;
    }

    /**
     * Set the value of the CZRKHYZK column.
     * @param czrkhyzk
     */
    public void setCzrkhyzk(java.lang.String czrkhyzk)
    {
        this.czrkhyzk = czrkhyzk;
    }

    /**
     * Return the value of the CZRKBYZK column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkbyzk()
    {
        return this.czrkbyzk;
    }

    /**
     * Set the value of the CZRKBYZK column.
     * @param czrkbyzk
     */
    public void setCzrkbyzk(java.lang.String czrkbyzk)
    {
        this.czrkbyzk = czrkbyzk;
    }

    /**
     * Return the value of the CZRKSG column.
     * @return java.lang.String
     */
    public java.lang.String getCzrksg()
    {
        return this.czrksg;
    }

    /**
     * Set the value of the CZRKSG column.
     * @param czrksg
     */
    public void setCzrksg(java.lang.String czrksg)
    {
        this.czrksg = czrksg;
    }

    /**
     * Return the value of the CZRKZY column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkzy()
    {
        return this.czrkzy;
    }

    /**
     * Set the value of the CZRKZY column.
     * @param czrkzy
     */
    public void setCzrkzy(java.lang.String czrkzy)
    {
        this.czrkzy = czrkzy;
    }

    /**
     * Return the value of the CZRKFWCS column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkfwcs()
    {
        return this.czrkfwcs;
    }

    /**
     * Set the value of the CZRKFWCS column.
     * @param czrkfwcs
     */
    public void setCzrkfwcs(java.lang.String czrkfwcs)
    {
        this.czrkfwcs = czrkfwcs;
    }

    /**
     * Return the value of the CZRKZZ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkzz()
    {
        return this.czrkzz;
    }

    /**
     * Set the value of the CZRKZZ column.
     * @param czrkzz
     */
    public void setCzrkzz(java.lang.String czrkzz)
    {
        this.czrkzz = czrkzz;
    }

    /**
     * Return the value of the CZRKXP column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkxp()
    {
        return this.czrkxp;
    }

    /**
     * Set the value of the CZRKXP column.
     * @param czrkxp
     */
    public void setCzrkxp(java.lang.String czrkxp)
    {
        this.czrkxp = czrkxp;
    }

    /**
     * Return the value of the CZRKXXJB column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkxxjb()
    {
        return this.czrkxxjb;
    }

    /**
     * Set the value of the CZRKXXJB column.
     * @param czrkxxjb
     */
    public void setCzrkxxjb(java.lang.String czrkxxjb)
    {
        this.czrkxxjb = czrkxxjb;
    }

    /**
     * Return the value of the CZRKZXBS column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkzxbs()
    {
        return this.czrkzxbs;
    }

    /**
     * Set the value of the CZRKZXBS column.
     * @param czrkzxbs
     */
    public void setCzrkzxbs(java.lang.String czrkzxbs)
    {
        this.czrkzxbs = czrkzxbs;
    }

    /**
     * Return the value of the CZRKXJGAJGMC column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkxjgajgmc()
    {
        return this.czrkxjgajgmc;
    }

    /**
     * Set the value of the CZRKXJGAJGMC column.
     * @param czrkxjgajgmc
     */
    public void setCzrkxjgajgmc(java.lang.String czrkxjgajgmc)
    {
        this.czrkxjgajgmc = czrkxjgajgmc;
    }

    /**
     * Return the value of the CZRKXJGAJGJGDM column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkxjgajgjgdm()
    {
        return this.czrkxjgajgjgdm;
    }

    /**
     * Set the value of the CZRKXJGAJGJGDM column.
     * @param czrkxjgajgjgdm
     */
    public void setCzrkxjgajgjgdm(java.lang.String czrkxjgajgjgdm)
    {
        this.czrkxjgajgjgdm = czrkxjgajgjgdm;
    }

    /**
     * Return the value of the CZRKPCSMC column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkpcsmc()
    {
        return this.czrkpcsmc;
    }

    /**
     * Set the value of the CZRKPCSMC column.
     * @param czrkpcsmc
     */
    public void setCzrkpcsmc(java.lang.String czrkpcsmc)
    {
        this.czrkpcsmc = czrkpcsmc;
    }

    /**
     * Return the value of the CZRKPCSJGDM column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkpcsjgdm()
    {
        return this.czrkpcsjgdm;
    }

    /**
     * Set the value of the CZRKPCSJGDM column.
     * @param czrkpcsjgdm
     */
    public void setCzrkpcsjgdm(java.lang.String czrkpcsjgdm)
    {
        this.czrkpcsjgdm = czrkpcsjgdm;
    }

    /**
     * Return the value of the CZRKXXTQSJ column.
     * @return java.lang.String
     */
    public java.lang.String getCzrkxxtqsj()
    {
        return this.czrkxxtqsj;
    }

    /**
     * Set the value of the CZRKXXTQSJ column.
     * @param czrkxxtqsj
     */
    public void setCzrkxxtqsj(java.lang.String czrkxxtqsj)
    {
        this.czrkxxtqsj = czrkxxtqsj;
    }

    /**
     * Return the value of the YHBPACKAGENAME column.
     * @return java.lang.String
     */
    public java.lang.String getYhbpackagename()
    {
        return this.yhbpackagename;
    }

    /**
     * Set the value of the YHBPACKAGENAME column.
     * @param yhbpackagename
     */
    public void setYhbpackagename(java.lang.String yhbpackagename)
    {
        this.yhbpackagename = yhbpackagename;
    }

    /**
     * Return the value of the YHBGABTIME column.
     * @return java.util.Date
     */
    public java.sql.Timestamp getYhbgabtime()
    {
        return this.yhbgabtime;
    }

    /**
     * Set the value of the YHBGABTIME column.
     * @param date
     */
    public void setYhbgabtime(java.sql.Timestamp date)
    {
        this.yhbgabtime = date;
    }

    /**
     * Implementation of the equals comparison on the basis of equality of the primary key values.
     * @param rhs
     * @return boolean
     */
    public boolean equals(Object rhs)
    {
        if (rhs == null)
            return false;
        if (! (rhs instanceof Jbxx))
            return false;
        Jbxx that = (Jbxx) rhs;
        if (this.getCzrkryid() == null || that.getCzrkryid() == null)
            return false;
        return (this.getCzrkryid().equals(that.getCzrkryid()));
    }

    /**
     * Implementation of the hashCode method conforming to the Bloch pattern with
     * the exception of array properties (these are very unlikely primary key types).
     * @return int
     */
    public int hashCode()
    {
        if (this.hashValue == 0)
        {
            int result = 17;
            int czrkryidValue = this.getCzrkryid() == null ? 0 : this.getCzrkryid().hashCode();
            result = result * 37 + czrkryidValue;
            this.hashValue = result;
        }
        return this.hashValue;
    }
}


i don't know why the POJO class need implements Serializable?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 7:08 am 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
Hi,
Who saied there is a need to implement Serializable?

If you want you are allowed not to implement Serialziable. But if you want to pass the POJO on a distributed system (for example using remote session EJBs) you must implement Serializable.

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
 Post subject: Not just distributed
PostPosted: Mon Aug 15, 2005 11:26 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
If your objects are going to be stored in the session scope then implementing Serializable helps to avoid surprices on HttpSession passivation/activation.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.