• 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

hibernate

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why serializable interface has taken in hibernate get function i.e POJO pojo=session.get(POJO.class ,serializable szlr);
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It expects the @Id field to be Serializable. This will usually be the case anyway if it is a basic type like Integer or Long, however often times people will have Embedded classes or Primary Key classes to support composite keys. In this case these objects must also implement Serializable.

So what you have there is this:

 
hari vallabh shukla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we do not implement serializable interface on POJOID class so JVM take responsibility to implement for us
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

we do not implement serializable interface on POJOID class



JSR-317 requires it so you need to.


so JVM take responsibility to implement for us



What leads you to believe this is going to happen? The JVM is not going to just make something Serializable for you. In 99% of cases it is as simple as adding 'implements Serializable' to your ID class and having your IDE generate a serial version id. You can make this change in less time than it takes me to type this.
 
hari vallabh shukla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i understand that POJOId class implement serializable interface but some time we give Integer,Long ,String etc in ID field which donot implement serializable interface then how compiler handle that situation
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those classes you mentioned do implement Serializable. Look at the implemented interfaces on the API.

http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html
 
hari vallabh shukla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for giving your knowlege, now my doubt has cleared
 
hari vallabh shukla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why serializable interface has taken in hibernate get function i.e POJO pojo=session.get(POJO.class ,serializable szlr); I ant to ask why not Object class has taken instead of serialization
 
hari vallabh shukla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By studying book i got an idea that one of the use of Serializable interface is that to convert object into bytestream and store in file or database ,so to convert POJOId object into relational structure which database can understand serializable interface has taken
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic