File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Persistence session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Persistence session " Watch "Persistence session " New topic
Author

Persistence session

vaagesh Chnadra
Greenhorn

Joined: Jan 06, 2010
Posts: 6
Hi All,

Does Objects those placed in "Persistence session" must be serilalizable also required to over write hashcode() and equals methods.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

What exactly do you mean by "Persistence session"??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
vaagesh Chnadra
Greenhorn

Joined: Jan 06, 2010
Posts: 6
OK Ankit,

I will elaborate my question in detail

Clarification 1:

Objects placed in HTTP Session must be Serilizable and also should over write equals() and hashcode() methods

Clarification 2:
Objects placed in Hibernate Session must be Serilizable and also should over write equals() and hashcode() methods
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Which session are we talking about here, an HttpSession or Hibernate's Session? Or both?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
I know of no reason to create equals and hashcode methods for objects serialized by the HTTP - Servlet API session mechanisms. After all, it is the String name that is used to recover the object reference.

Bill
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

William Brogden wrote:I know of no reason to create equals and hashcode methods for objects serialized by the HTTP - Servlet API session mechanisms. After all, it is the String name that is used to recover the object reference.

Bill


What about clusters?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
What about clusters?


I dunno, what about clusters, why would a session shared between clustered servers treat the retrieval of a reference differently?

Looking forward to expanding my understanding...

Bill
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30752
    
156

For clusters, you need to implement Serializable to be able to write to and read from disk. I don't see why you would need equals() and hashCode() though.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

It is a popular misconception that hashCode provides a unique identifier for an object. It does not. hashCode and equals are used for Object equality comparisons, not serialized retrieval.


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Persistence session