I m using Session.save()
method (in Hibernate) to persist my entity objects which returns an object of type java.io.Serializable
.
The returned value is the generated primary key for the entity.
The generated primary key is of type long
(or bigint).
问题是:我如何将返还价值转换成long
?
Serializable result = session.save(myEntityObject);
//This line of code fails.
long r = (long)result;