• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializable two times within a entity?

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • 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?
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Okay, then I put the "implements Serializable" both to the "class User" and the "static class UserID!

thanks:-)
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic