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.

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.

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

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

posted 4 years ago

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