Java Hibernate

Session

  openSession

    每次打开一个新的Session会话

  getCurrentSession

    始终是一个Session会话,类似工厂方法

    需要在hibernate.cfg.xml文件中添加配置:<property name="hibernate.current_session_context_class">thread</property>

主键自增

  在主键配置中增加native

    <id name="sid" column="sid">

      <generator class="native"/>

    </id>

猜你喜欢

转载自www.cnblogs.com/vincenshen/p/10241815.html