get auto generated key, on save, using hibernate + spring mvc

前端 未结 3 1979
囚心锁ツ
囚心锁ツ 2021-01-14 04:26

I am using Spring MVC + Hibernate

@Resource(name = \"sessionFactory\")
private SessionFactory sessionFactory;

// save
public  int         


        
3条回答
  •  鱼传尺愫
    2021-01-14 04:35

    Try this instead. This works with latest Hibernate (version 4.1) also.

    session.persist(object);
    object.getId();
    

提交回复
热议问题