• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Persistence session

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly do you mean by "Persistence session"??
 
vaagesh Chnadra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which session are we talking about here, an HttpSession or Hibernate's Session? Or both?

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic