-->
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: one to many mapping
PostPosted: Sat Apr 13, 2013 5:59 am 
Newbie

Joined: Fri Apr 12, 2013 1:53 am
Posts: 18
There are two POJO classes employee and certificates which has one to many mapping. The following is a method in certificates class. What is the purpose of this method?

public boolean equals(Object obj) {
if (obj == null) return false;
if (!this.getClass().equals(obj.getClass())) return false;
Certificate obj2 = (Certificate)obj;
if((this.id == obj2.getId()) && (this.name.equals(obj2.getName())))
{
return true;
}
return false;
}

There is this other code called hashCode. what is its purpose?
public int hashCode() {
int tmp = 0;
tmp = ( id + name ).hashCode();
return tmp;
}
}


Top
 Profile  
 
 Post subject: Re: one to many mapping
PostPosted: Mon Apr 15, 2013 4:29 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Since these two methods are overrides of methods defined in java.lang.Object
you find a good description here:
http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html


Top
 Profile  
 
 Post subject: Re: one to many mapping
PostPosted: Mon Apr 15, 2013 7:16 am 
Beginner
Beginner

Joined: Thu May 17, 2007 9:56 am
Posts: 21
Location: India
I guess the Certificate class has some super class. You may need to go through the full code flow.

_________________
Kuzhali


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.