javaAndBeyond
javaAndBeyond

Reputation: 540

Why does Save() of Hibernate session return Serializable?

The identifier returned after save method in hibernate session should implement serializable. Why is it so? Is Serilizable the only common interface of all the wrapper classes? Isnt there any other elegant approach to deal with this polymorphism? IMO, it should be Number Class, thats returned.

Upvotes: 1

Views: 1002

Answers (1)

Alex Barnes
Alex Barnes

Reputation: 7218

When you pass an entity to Session.save Hibernate returns you the generated identifier for that entity. This could be any class:

  • Number
  • String
  • @Embeddable

So there isn't really a way it can pass you something more useful than that. Certainly a number wouldn't work in all circumstances.

Upvotes: 2

Related Questions