There is no log error in runtime. When I shutdown my tomcat and restart
it then refresh my page, I found out that the name is null. Before it
has a value, only when I restarted my tomcat it became null. How come
this occurs? How can I prevent it? When I used
HashCodeBuilder.reflectionHashCode(this) in my hashCode, I have an error
in my runtime LazyInitializationException... What will be the possible
solution in my log error?
Thanks for continues answering Ealden.
Adriel
On Mon, 2007-09-17 at 18:01 +0800, Ealden Escañan wrote:
> On 9/17/07, adriel manalansan <[EMAIL PROTECTED]> wrote:
> > Hello everybody,
> >
> > I think this is a stupid question but I really cant make it work. I am
> > using appfuse 1.9.4 and webwork. In appfuse, it is default that
> > BaseObject class implements java.io.Serializable. I have a superclass
> > named BaseModel:
> >
> > public abstract class BaseModel extends BaseObject implements
> > Serializable {
> >
> > private Long id;
> >
> >
> > public Long getId() {
> > return id;
> > }
> >
> > public void setId(Long id) {
> > this.id = id;
> > }
> >
> > }
> >
> >
> > and I have a Study object:
> >
> > public class Study extends BaseModel implements Comparable<Study> {
> > private static final long serialVersionUID = 12345L;
> >
> >
> > private String name;
> > private Set<StudyPageSet> studyPageSets = new TreeSet();
> > private Set<StudyPage> studyPages = new TreeSet();
> >
> > public Study() {}
> >
> > public Study( String name ){
> > this.setName(name);
> > }
> >
> >
> > public Set<StudyPageSet> getStudyPageSets() {
> > return studyPageSets;
> > }
> >
> > public void setStudyPageSets(Set<StudyPageSet> studyPageSets) {
> > this.studyPageSets = studyPageSets;
> > }
> >
> > public void addStudyPageSets( StudyPageSet studyPageSet ){
> > studyPageSet.setParentStudyHead(this);
> > this.studyPageSets.add(studyPageSet);
> > }
> >
> > public void removeStudyPageSet( StudyPageSet studyPageSet ){
> > studyPageSet.setParentStudyHead(null);
> > this.studyPageSets.remove(studyPageSet);
> > }
> >
> > public int compareTo( Study study ) {
> > if ( this.sortOrder < study.getSortOrder() )
> > return -1;
> > if ( this.sortOrder == study.getSortOrder() )
> > return 0;
> > else
> > return 1;
> > }
> >
> > public boolean equals(Object o) {
> > if (!(o instanceof Study))
> > return false;
> > Study n = (Study)o;
> > return n.getName().equals(name) &&
> > n.getId().equals(this.getId());
> > }
> >
> > public int hashCode() {
> > return 31*name.hashCode();
> > }
> >
> > public String toString() {
> > return name;
> > }
> >
>
> I don't think there's a problem with Serializable. You get a
> NullPointerException because name is null when you invoke it's
> hashCode() method. Add a check if name is null or use
> HashCodeBuilder.reflectionHashCode(this)
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]