Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Serializable two times within a entity?

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have something like this:



My Question is:
Do I need (have to) put the "implements Serializable" both to the "class User" and the "static class UserID"?

Or is it enough to do it only within the "static class UserID" (or better "class User"?)?

Does it makes a difference?
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its enough to put it to the UserID however its not a bad idea to have your entities serialaizable so that in case your web app. is used in a distributed environment then your objects will be able to move from one VM to another without problems. ;)

(peace)
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, then I put the "implements Serializable" both to the "class User" and the "static class UserID!

thanks:-)
 
Ranch Hand
Posts: 84
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

omar al kababji wrote:Its enough to put it to the UserID however its not a bad idea to have your entities serialaizable so that in case your web app. is used in a distributed environment then your objects will be able to move from one VM to another without problems. ;)

(peace)



I believe that it's a requirement that the Primary Keys of any entity must be serializable.

regards,
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Angel Taveras wrote:

I believe that it's a requirement that the Primary Keys of any entity must be serializable.

regards,



yes thats exactly what i meant by its enough for the UserId which is the primary key ;), actually if you look at the load or get methods of the session object of hibernate you will notice that the second parameter that is the primary key should be serializable.

however its not bad to always make your classes serializable if you can, since many frameworks depends on that to move objects back and forth on the network in distributed applications ;)


(peace)
 
reply
    Bookmark Topic Watch Topic
  • New Topic