get auto generated key, on save, using hibernate + spring mvc
问题 I am using Spring MVC + Hibernate @Resource(name = "sessionFactory") private SessionFactory sessionFactory; // save public <T> int save(T entity) throws DataAccessException { Session session = sessionFactory.getCurrentSession(); session.save(entity); } As New Record Save , New Primary Key generated which in auto increment (db.MySQL). I want to get and return the new auto incremented value with respect to the above method. Update me ! 回答1: Save method should return generated ID: http://docs