Reputation: 540
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
Reputation: 7218
When you pass an entity to Session.save
Hibernate returns you the generated identifier for that entity. This could be any class:
@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