Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persistence session

 
vaagesh Chnadra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Does Objects those placed in "Persistence session" must be serilalizable also required to over write hashcode() and equals methods.
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean by "Persistence session"??
 
vaagesh Chnadra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which session are we talking about here, an HttpSession or Hibernate's Session? Or both?

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic